开发者

getFriendsTimeline Returning Nothing

I'm using the Twitterlibphp for a Twitter project and using the getFriendsTimeline() method to get my Home timeline. The problem is that with this code:

<?php 
    // require the twitter library
    require "scripts/twitter.lib.php";

    // your twitter username and password
    $username = "MyUser";
    $password = "MyPass";

    // initialize the twitter class
    $twitter = new Twitter($use开发者_StackOverflow中文版rname, $password);

    // fetch public timeline in xml format
    $options = array("count" => 20);
    $xml = $twitter->getFriendsTimeline($options);
    //$xml = $twitter->getPublicTimeline();

    $twitter_status = new SimpleXMLElement($xml);
    foreach($twitter_status->status as $status) {
        foreach($status->user as $user) {
                echo '<li class="tweet"><img src="' . $user->profile_image_url . '" class="twitter_image">';
                echo '<a href="http://www.twitter.com/' . $user->name . '">' . $user->name . '</a>: ';
        }
        echo $status->text;
        echo '<br/>';
        echo '<div class="twitter_posted_at">Posted at: ' . $status->created_at . '</div>';
        echo "</li>";
    }
?>

When I tried to echo $xml I got this response:

Basic authentication is not supported

What I'm doing wrong?

Before I tried this code I was using the getPublicTimeline() correctly and without any problems.

PS: On my source code the $username and $password variables are correct and using my credentials


From a cursory glance of the source code provided, and with little knowledge of Twitterlibphp, it seems as though you're seeing the error you've mentioned because Twitter has recently dropped support for HTTP Basic Auth.

As documented here, OAuth is the new authentication standard required of all Twitter applications. For a popular PHP implementation of Twitter OAuth support, see abraham's GitHub project TwitterOAuth.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜