2011-02-07 7 views
1

おはよう、 は見回しましたが、答えを得ることはできませんでした。基本的に私の手を与えることができます誰にでもstatus/user_timelineから "in_reply_to_status_id"を取得するAPIの

<?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; 
?> 

おかげでHERESに私が書いたものが、無駄に、「in_reply_to_status_id」値statuses/user_timelineを取得し、PHP($のreplycheck)で変数として設定しようとしています!

+0

ステータスが他のものへの返信ではない場合はどうなりますか? – Arvin

+0

Nullを返すだけです – DexCurl

+0

Twitterの最新のバージョンでは、$ reply_result = $ oauth-> get( 'statuses/user_timeline'、array( 'screen_name' => 'jwhelton'))のようなリクエストを作成する必要があります。 – abraham

答えて

2

お使いのブラウザでhttp://api.twitter.com/1/statuses/user_timeline.json?screen_name=jwheltonを確認してください。

使用:in_reply_to_status_id_str id番号は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; 
} 
+0

最後のつぶやきが別のつぶやきに返信していることを確認しても、私のためにはうまくいかなかった:S – DexCurl

+0

@dexcurl最初の結果を得るには '$ reply_result [0] - > in_reply_to_status_id_str'を使う。 – Arvin

+0

紳士と学者に感謝します:) – DexCurl

関連する問題