我想知道爲什麼下面的代碼,我試圖用來拉最新推文的Twitter的飼料,不工作?Twitter信息源不符合代碼?
CODE:
<?
$username = "readitforward";
$limit = 5;
$feed = 'http://twitter.com/statuses/user_timeline.rss?screen_name='.$username.'&count='.$limit;
$tweets = file_get_contents($feed);
$tweets = str_replace("&", "&", $tweets);
$tweets = str_replace("<", "<", $tweets);
$tweets = str_replace(">", ">", $tweets);
$tweet = explode("<item>", $tweets);
$tcount = count($tweet) - 1;
for ($i = 1; $i <= $tcount; $i++) {
$endtweet = explode("</item>", $tweet[$i]);
$title = explode("<title>", $endtweet[0]);
$content = explode("</title>", $title[1]);
$content[0] = str_replace("–", "—", $content[0]);
$content[0] = preg_replace("/(http:\/\/|(www\.))(([^\s<]{4,68})[^\s<]*)/", '<a href="http://$2$3" target="_blank">$1$2$4</a>', $content[0]);
$content[0] = str_replace("$username: ", "", $content[0]);
$content[0] = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $content[0]);
$content[0] = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $content[0]);
$mytweets[] = $content[0];
}
while (list(, $v) = each($mytweets)) {
$tweetout .= "<div>$v</div>\n";
}
?>
輸出錯誤:
Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /data/24/1/0/139/1815302/user/1967139/htdocs/RIF/wp-content/themes/crown_readitforward2012/sidebar.php on line 93
Warning: file_get_contents(http://twitter.com/statuses/user_timeline.rss?screen_name=readitforward&count=5) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /data/24/1/0/139/1815302/user/1967139/htdocs/RIF/wp-content/themes/crown_readitforward2012/sidebar.php on line 93
Warning: Variable passed to each() is not an array or object in /data/24/1/0/139/1815302/user/1967139/htdocs/RIF/wp-content/themes/crown_readitforward2012/sidebar.php on line 114
93行:$tweets = file_get_contents($feed);
線:while (list(, $v) = each($mytweets)) {
我做了什麼錯在這裏???
非常感謝的說明;我需要創建一個php.ini文件。我已經在Wordpress安裝的根目錄下創建了這個文件;但我應該在那裏編碼來做出這個改變?非常感謝。 – 2012-04-20 15:03:09
'phpinfo()'應該告訴你現在的位置在哪裏。 – alex 2012-04-20 15:06:48
再次感謝,但我該如何處理該片段以查找.ini文件? – 2012-04-20 15:20:42