您好我目前使用twitter API,并且无法获取鸣叫的created_at日期。返回的日期看起来就像我要求API的日期,而不是推文的发布日期。Twitter API搜索Get Tweet created_at时间
我能够得到这个日期,但如果它的日期我称为API它对我没有用处。 API返回了100条推文,每个created_at日期都完全相同?
这是我写的代码:
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$content = $connection->get("account/verify_credentials");
$tweets = $connection->get("search/tweets", ["q" => "#TRIG", "result_type" => "recent", "count" => 100]);
print_r($tweets);
我使用这行代码来获取created_at日期:
$tweetCreatedTime = $tweets->statuses[0]->created_at;
这是我使用计数的所有代码推文:
$timeHourAgo = time() - 3600;
$count = 0;
$tweetCoinCount = [];
for ($i=0; $i < round((count($coinSymbol) * 0.06)); $i++) {
$tweets = $connection->get("search/tweets", ["q" => "#" + $coinSymbol[$i], "result_type" => "recent", "count" => 100]);
$tweetsCount = count($tweets->statuses);
for ($t=0; $t < $tweetsCount; $t++) {
$tweetCreatedTime = $tweets->statuses[$t]->created_at;
$tweetCreatedTimestamp = strtotime($tweetCreatedTime);
if ($tweetCreatedTimestamp > $timeHourAgo) {
$count = $count + 1;
}
}
$tweetCoinCount[$coinSymbol[$i]] = $count;
$count = 0;
}
$ coinSymbol只是一串不同的货币,我使用另外一个API
返回的所有推文都具有相同的created_at日期。
我刚刚试过了,它的返回差异日期,只有第一个是'Wed Oct 04 11:24:19 +0000 2017',你能展示你如何通过推文循环。 –
你只能通过'$ tweetCreatedTime = $ tweets-> statuses [0] - > created_at获得第一条推文的日期,'''''''''''''''' – 3gth
我已编辑我的问题,告诉你我循环使用 –