<?php

    function get_retweeters($tweet_id) {
      $consumer_key = 'Ulo3TVBXZVphWnBuelVQV2JqaWU6MTpjaQ';
      $consumer_secret = 'iMBRWRvDZHQunqDyoQkkcZCwPzI6IRqiuHl0ws2tV48bcN9m2X';
      $access_token = '1600894902501445634-XKvpt37TZkUldXpMWi2WHYcYnYxKb3';
      $access_token_secret = 'vacJnWvCDQHbWOKLDqhDFg9YxyYhoVtklboYKFJzmCVuW';

      $oauth = array(
        'oauth_consumer_key' => $consumer_key,
        'oauth_nonce' => time(),
        'oauth_signature_method' => 'HMAC-SHA1',
        'oauth_token' => $access_token,
        'oauth_timestamp' => time(),
        'oauth_version' => '1.0'
      );

      $oauth = array_map("rawurlencode", $oauth);
      ksort($oauth);

      $base_string = '';
      foreach($oauth as $key=>$value) {
        $base_string .= "$key=$value&";
      }

      $base_string = rtrim($base_string, "&");
      $base_string = "GET&" . rawurlencode("https://api.twitter.com/1.1/statuses/retweeters/ids.json") . "&" . rawurlencode($base_string);

      $signature_key = rawurlencode($consumer_secret) . "&" . rawurlencode($access_token_secret);
      $signature = base64_encode(hash_hmac('sha1', $base_string, $signature_key, true));
      $oauth['oauth_signature'] = $signature;

      $header = "Authorization: OAuth ";
      $values = array();

      foreach($oauth as $key=>$value) {
        $values[] = "$key=\"" . $value . "\"";
      }

      $header .= implode(", ", $values);
      $header .= "\r\n";
      $url = "https://api.twitter.com/1.1/statuses/retweeters/ids.json?id=".$tweet_id."&stringify_ids=true";

      $curl = curl_init();

      curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_URL => $url,
        CURLOPT_CAINFO => "C:/wamp64/www/twitt/cacert.pem",
        CURLOPT_HTTPHEADER => array($header),
        CURLOPT_ENCODING => 'gzip',
        CURLOPT_VERBOSE => true
      ));


      $response = curl_exec($curl);

      if($response === false) {
          echo "Error en la petición: " . curl_error($curl) . " (código " . curl_errno($curl) . ")";
      } else {
          // procesar la respuesta
      }
      curl_close($curl);

      return json_decode($response);
    }


$retweeters = get_retweeters(1653589380903124993);
print_r($retweeters);
?>