我正在使用twitter API來檢索我的所有推文。但是,我似乎無法獲得「expanded_url」和「hashtag」屬性。該特定API的文檔可在https://dev.twitter.com/docs/api/1/get/statuses/user_timeline找到。我的代碼如下:我怎樣才能通過這個數組來獲得我需要的東西?
$retweets = 'http://api.twitter.com/1/statuses/user_timeline.json? include_entities=true&include_rts=true&screen_name=callmedan';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $retweets);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlout = curl_exec($ch);
curl_close($ch);
$response = json_decode($curlout, true);
$tweet_number = count($response);
for($i = 0;$i < $tweet_number;$i++)
{
$url = $response['entities']['urls'];
$hashtag = $response['entities']['hashtags'];
$text = $response[$i]['text'];
echo "$url <br />";
echo "$hashtag <br />";
echo "$text <br />";
echo "<br /><br />";
}
我得到一個錯誤信息閱讀「公告:未定義指數:實體。」
有什麼建議嗎?
'回聲的var_dump($響應);',並確保你所訪問您認爲是在那裏的數據(確保索引數組中存在)。這也是一個很好的方式來直觀地看到你想要檢索的東西。 –