0

I am using twitter api to get the retweets , for a particular tweets

 $url =    "https://api.twitter.com/1.1/statuses/retweet/830785820722343937.json";
 $requestMethod = 'POST';
  $getfield = "";

 $twitter = new TwitterAPIExchange($settings);
 $string = $twitter->setGetfield($getfield)
         ->buildOauth($url, $requestMethod)
         ->performRequest();
 $string = json_decode($string,$assoc = TRUE);

But getting this error

[code] => 32 [message] => Could not authenticate you.

Please help

beginner
  • 2,366
  • 4
  • 29
  • 53
  • Are your `$settings` correct? What requests are working? The `$url` and `$requestMethod` used above are meant to retweet `$tweet[id]`, not getting its retweets. See https://dev.twitter.com/rest/reference/get/statuses/retweets/id for fetching a collection of the 100 most recent retweets of a Tweet. – pii_ke Feb 12 '17 at 15:28
  • @pii_ke , hey thanks for your comment , setting is correct , search request is working fine , i updated my code, please can u find any solution – beginner Feb 12 '17 at 15:44

1 Answers1

1

Try after replacing the $url and $requestMethod as follows.

$url = "https://api.twitter.com/1.1/statuses/retweets/830785820722343937.json";
$requestMethod = 'GET';

See https://dev.twitter.com/rest/reference/get/statuses/retweets/id for more.

As I mentioned in comment, the $url and $requestMethod used in your code are not for getting retweets. You are using something else, see https://dev.twitter.com/rest/reference/post/statuses/retweet/id to leaarn about it and find the difference.

pii_ke
  • 2,811
  • 2
  • 20
  • 30
  • Hey i find the problem, I try ;$string = $twitter ->buildOauth($url, $requestMethod) ->performRequest(); , Thanks – beginner Feb 12 '17 at 16:05
  • @beginner are you getting retweets without changing the `$url`? – pii_ke Feb 12 '17 at 16:14
  • hey thanks, but i have another problem i want to add count parameter , i tried "statuses/retweets/509457288717819904.json?count=100 but not working , please help – beginner Feb 12 '17 at 18:37
  • set `$getfield = '?count=100' ;` and use `setGetfield($getfield)` before calling`buildOauth()` like in the last example shown at https://github.com/J7mbo/twitter-api-php – pii_ke Feb 12 '17 at 18:55