Php Twitter API-如何通过标签统计过去24小时内的推文?

Php Twitter API-如何通过标签统计过去24小时内的推文?,php,json,api,twitter,twitter-oauth,Php,Json,Api,Twitter,Twitter Oauth,我试着使用twitterapi,我想统计一下在过去24小时内有多少条tweet被推到了包含一个特殊标签的位置 我真的找不到这样做的方法?似乎限制在100个以内 为了在我的网站上设置一些统计数据,我需要获得过去24小时内的推文数量 当前代码: <?php ini_set('display_errors', 1); require_once('TwitterAPIClass/TwitterAPIExchange.php'); /** Set access tokens here - see:

我试着使用twitterapi,我想统计一下在过去24小时内有多少条tweet被推到了包含一个特殊标签的位置

我真的找不到这样做的方法?似乎限制在100个以内

为了在我的网站上设置一些统计数据,我需要获得过去24小时内的推文数量

当前代码:

<?php
ini_set('display_errors', 1);
require_once('TwitterAPIClass/TwitterAPIExchange.php');

/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
    'oauth_access_token' => "XXXX",
    'oauth_access_token_secret' => "YYYY",
    'consumer_key' => "XXXX",
    'consumer_secret' => "YYYY"
);    

/** Perform a GET request and echo the response **/
/** Note: Set the GET field BEFORE calling buildOauth(); **/
$url = 'https://stream.twitter.com/1.1/statuses/filter.json';
$getfield = '?track=%23beer';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$twitter_data = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), true);

foreach($twitter_data['statuses'] as $tweets) {
    echo $tweets['created_at'] . '<br>';

}            
?>

这可能不是完美的答案,但我假设你的假设是正确的。twitterrestapi已经是一个指标。(我知道您正在使用流API,但让我解释一下)

由于twitterapi都遵循API开发人员自己设置的一般规则,因此我假设streamapi遵循与restapi相同的规则。返回的tweet数量限制为100的状态文档(参数:
count
)。尽管流媒体和RESTAPI之间没有明显的联系,文档中也没有描述,但我认为这就是为什么数组中只有100个元素的原因


如果可能的话,您可以运行一个脚本,在一定的时间间隔内向服务器发送请求,然后将单个tweet保存在数据库/文本文件/任何文件中。由于请求频率的调节设置为每15分钟15次或每15分钟180次,这将是一个解决办法。

Hmm好的。。我想我会试着循环一下。。非常感谢您的评论!!:)