Twitter PHP检索最新推文

Twitter PHP检索最新推文,twitter,php,Twitter,Php,我目前正在使用以下代码从我的推特提要检索最新推特: <?php $username='myUsername'; $format = 'json'; $tweet = json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}")); $latestTweet = htmlentities($tweet[0]->t

我目前正在使用以下代码从我的推特提要检索最新推特:

<?php
    $username='myUsername';
    $format = 'json';
    $tweet = json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}"));
    $latestTweet = htmlentities($tweet[0]->text, ENT_QUOTES);
    $latestTweet = preg_replace('/http:\/\/([a-z0-9_\.\-\+\&\!\#\~\/\,]+)/i', '<a href="http://$1" target="_blank">http://$1</a>', $latestTweet);
    $latestTweet = preg_replace('/@([a-z0-9_]+)/i', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $latestTweet);
    echo '<p class="inset white">'.$latestTweet.'</p>';
?>

在MAMP上,这非常有效,但是在我的实时站点上,我什么也没有得到,甚至连服务器端的错误消息都没有。我在一篇类似的帖子上读到,这可能与php.ini中没有设置
allow\u url\u fopen=on有关,但设置似乎没有什么不同


尽管Twitter可能已经改变了他们对API使用的政策(我不相信他们已经改变了),但我不知道问题出在哪里。

我以前也使用过同样的方法,但不幸的是,它使用的是Twitter API v1,v1不再可用(查看更多详细信息)。您现在需要具有OAuth使用者和用户访问权限。GitHub Thematthharris的tmhOAuth库可以方便地显示Twitter提要

您可以查看我在stackoverflow发布的问题,作为您问题的参考:


它已经有了如何访问需要在Twitter中检索的公共信息的代码。

(提示)欢迎使用Stack Overflow。请在回答中总结链接;这样,如果链接过时,答案也不会完全无用。