从 Twitter API 1 切换到 1.1(添加身份验证)


Switching from Twitter API 1 to 1.1 (adding auth)

目前我使用此代码检索时间线上的最新 6 条推文。我阅读了 Twitter 文档,但我无法理解如何实现我创建的应用程序的身份验证密钥。

    <?php
    $json = wp_remote_get("http://api.twitter.com/1/statuses/user_timeline/username.json?count=6", true);
    $decode = json_decode($json['body'], true);
    echo "
        <ul style='color:#6E6E6E'>";
        $count = count($decode); //counting the number of status
        for($i=0;$i<$count;$i++){ echo '
        <li>'.$decode[$i]['text'].'<br><a href='; echo '"http://twitter.com/#!/'.$decode[0][user][name].'/status/'.$decode[$i][id].'"><small>'. strftime('%e %B',strtotime($decode[$i]['created_at'])) ."</small></a> - <a href='http://twitter.com/intent/tweet?in_reply_to=".$decode[$i][id]."'><small>rispondi</small></a> - <a href='http://twitter.com/intent/retweet?tweet_id=".$decode[$i][id]."'><small>retweet</small></a> - <a href='http://twitter.com/intent/favorite?tweet_id=".$decode[$i][id]."'><small>preferito</small></a></li>";} echo "
        </ul>
    ";
    ?>

http://ronzohan.blogspot.com/2013/01/how-to-connect-in-twitter-using-php.html,你可以尝试看看Twitteroauth如何工作的解释。