简体   繁体   English

Twitter user_timeline.json仅显示最新的tweet,即使count = 5

[英]Twitter user_timeline.json showing only latest tweet even though count = 5

The following PHP code used to work then this morning suddenly the following call 下面的PHP代码曾经起作用,然后今天早上突然进行了以下调用

$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! 即使我将count设置为5并且有数百条tweets,也仅返回一个结果为$ get_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. 我看到的唯一原因是以前的推文是15天前,但是我希望最近的5条推文而不是少于X天的最新5条推文。

The library is the one available at https://github.com/andrewbiggart/latest-tweets-php-o-auth/ by the way. 顺便说一下,该库是https://github.com/andrewbiggart/latest-tweets-php-o-auth/上可用的库。

EDIT: 编辑:

$include_rts = false

$exclude_replies = false;

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. 它正确地向我返回了5条推文,但是我注意到它不时仅返回1条推文,但这在Twitter方面一定是一个问题。

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. 在这种情况下,您应该忽略更新缓存并使用它而不是返回的单个tweet。

Twitter user_timeline.json showing only latest tweet even though count = 5 Twitter user_timeline.json仅显示最新的tweet,即使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. Twitter方面不是问题。 Yes, Twitter will return the tweets how much you specified in count & if you didn't specified, it will return 15 tweets. 是的, Twitter会返回推文中您在count指定的count ;如果未指定,它将返回15条推文。


So, Why Twitter returned only one tweet? 那么,为什么Twitter仅返回一条推文?

It's because you used some additional parameters along with your request like 这是因为您在请求中使用了一些其他参数,例如

  1. include_rts and include_rts
  2. exclude_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. 因为你没有提供有关您是否启用retweetsexcluded_replies与否,我无法明确指出你,你犯的错误。

But, most likely you're getting few tweets because of omitting Retweets or Replies or Both. 但是,最有可能是由于省略了“转发”或“回复”或“两者兼而有之”而获得的推文很少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM