从API PHP中的statuses / user_timeline Twitter获取“in_reply_to_status_id”

时间:2011-02-07 17:10:28

标签: php json api twitter

嘿伙计们, 环顾四周但却无法得到答案或自己想出来。基本上尝试获取“in_reply_to_status_id”值statuses/user_timeline并将其设置为php($ replycheck)中的变量,这是我写的但是无济于事

<?php
$consumerKey    = 'x';
$consumerSecret = 'x';
$oAuthToken     = 'x';
$oAuthSecret    = 'x';
// Create Twitter API objsect and fake a user agent to have higher rate limit
require_once("twitteroauth.php");
$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
$oauth->useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9';

$reply_result = $oauth->get('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=jwhelton');
$tweetid = $reply_result ->id;
$checkreply = $reply_result ->in_reply_to_status_id;
echo "<br /><br />Last tweet  was id'd as ".$tweetid." and was reply of ".$checkreply;
?>

感谢任何能够帮助我的人!

1 个答案:

答案 0 :(得分:2)

请在浏览器上查看http://api.twitter.com/1/statuses/user_timeline.json?screen_name=jwhelton以查看。

使用:in_reply_to_status_id_str代替。身份证号码太高,PHP无法评估,因此它变为null。所以代码可以是:

$reply_result = $oauth->get('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=jwhelton');

foreach($reply_result as $i => $tweet) {
    $tweetid = $tweet->id_str;
    $checkreply = $tweet->in_reply_to_status_id_str;
    echo "<br /><br />Last tweet  was id'd as ".$tweetid." and was reply of ".$checkreply;
}