2011-03-24 121 views
0

我有搜索發現AF NICE和簡便的方法來獲得Twitter狀態的整個網絡,現在我找到了一個..但它不工作Twitter的API問題

我試試這個 http://tareq.wedevs.com/2009/05/playing-with-twitter-json-using-php/

但它說

「注意:使用未定義的常量文本 - 在/Applications/MAMP/htdocs/test/twitterWidget/twitter.php假定 '文' 上線8

iPad2的模擬器/ W CSS3,jQuery和HTML5 http://t.co/GaNMTbg via @altryne「

我需要做什麼?

+1

你應該接受更多的答案。 – bluefoot 2011-03-24 22:05:31

+0

我們肯定需要看到代碼的一部分失敗,以幫助你;) – Oleiade 2011-03-24 22:06:14

回答

0
<?php 
$json = file_get_contents("http://twitter.com/status/user_timeline/tareq_cse.json?count=10", true); 
$decode = json_decode($json, true); 

echo "<pre>"; 
$count = count($decode); //counting the number of status 
for($i=0;$i<$count;$i++){ 
echo $decode[$i]['text']."<br>"; // in the original code there was $decode[$i][text] which is not correct 
} 
echo "</pre>"; 
?> 

你必須把那文本指數的第8行到qoutes。我在這裏發佈了更正版本。

該網站上的最後一個代碼示例塊在其所有行中也具有相同的錯誤。您必須將字符串數組索引放入引號中以避免發出通知。

+0

感謝隊友,你認爲我可以得到推文:P ?,這是我希望得到,但我找不到一個很好的教程,如何使它 – Sjmon 2011-03-24 22:45:17

+0

我試過了,它很好地返回了推文。 – 2011-03-24 22:50:32