K
K
Kevin Mitnick2016-12-17 11:02:47
PHP
Kevin Mitnick, 2016-12-17 11:02:47

Why is the number of likes not coming to twitter api?

I make a GET request through the address bar of the browser and in 100% of cases I get the correct fav count for the tweet:
Request link (parameters input compartment):

https://api.twitter.com/1.1/statuses/lookup.json

Part of the response to this request:
17a8e02c9f3b4b26ae15f875239445f8.png
Next, I connect the PHP Twitter SDK and loop through the list of tweets that are checked for existence before sending the request. That is, I execute the same request to the Twitter Api in a loop, but through the Twitter SDK.
And in 99% of cases I get 0 instead of the correct fav count, occasionally the correct value comes to fav count. With what it can be connected ? Here's how I make a request through the SDK:
$twitter = new TwitterAPIExchange($this->settings);//тут на входе массив с данными приложения и токенами
$url = "https://api.twitter.com/1.1/statuses/lookup.json";
$getfield = '?trim_user=true&include_entities=false&id=' . $value;//В value собственно ID твита
$response = @json_decode($twitter->setGetfield($getfield)->buildOauth($url, $this->requestMethod)->performRequest());//Отправляем запрос на api

$response = $response[0];
if(isset($response->favorite_count)){
  $data["likes"] = $response->favorite_count;
}

I removed part of the code in this source so as not to divert your attention to other things. I can say for sure that there are no problems in other parts of the code, the point is in the response to the request. By the way, not a little important factor - every three requests in the cycle, the program pauses for 2 seconds, and with the limits on requests, in fact, everything is also OK.
Who has any thoughts on this matter? I would be grateful for any help, I work with Twitter for the first time, if anything. Don't be too harsh =)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question