Reputation: 667
The following PHP code used to work then this morning suddenly the following call
$get_tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitter_user_id . "&count=" . $tweets_to_display . "&include_rts=" . $include_rts . "&exclude_replies=" . $exclude_replies);
returns a $get_tweets with only one result even though I set count to 5 and I have many hundreds of tweets! The only reason I see is that the previous tweet was 15 days ago however I want the latest 5 tweets not the latest 5 tweets in less than X days.
The library is the one available at https://github.com/andrewbiggart/latest-tweets-php-o-auth/ by the way.
EDIT:
$include_rts = false
$exclude_replies = false;
Upvotes: 3
Views: 964
Reputation: 3881
Twitter user_timeline.json showing only latest tweet even though count = 5
$get_tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitter_user_id . "&count=" . $tweets_to_display . "&include_rts=" . $include_rts . "&exclude_replies=" . $exclude_replies);
It's not a problem with Twitter
side. Yes, Twitter
will return the tweets how much you specified in count
& if you didn't specified, it will return 15 tweets.
So, Why Twitter
returned only one tweet?
It's because you used some additional parameters along with your request like
include_rts
andexclude_replies
which returns only few tweets.
Since you didn't provided about whether you enabled retweets
and excluded_replies
or not, i couldn't clearly point out you where you made the mistake.
But, most likely you're getting few tweets because of omitting Retweets or Replies or Both.
Upvotes: 2
Reputation: 3257
It's correctly returning 5 tweets to me, however I noticed it returns only 1 from time to time but it must be a problem on Twitter side.
Probably from time to time they throttle the number of tweets independently of your request. You should in that case ignore updating the cache and use it instead of the returned single tweet.
Upvotes: 2