开发者

Can anybody help me with the twitter home_timeline api?

开发者 https://www.devze.com 2023-03-07 21:22 出处:网络
I have the following code $curl_handle = curl_init(); $api_url = \'http://api.twitter.com/1/statuses/home_timeline.json\';

I have the following code

    $curl_handle = curl_init();
    $api_url = 'http://api.twitter.com/1/statuses/home_timeline.json';
        curl_setopt($curl_handle, CURLOPT_URL, $api_url);
    if (true) {
        curl_setopt($curl_handle, CURLOPT_USERPWD, 'mytwitterusername:mypass');
    }
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:'));
    $twitter_data = curl_exec($curl_handle);
    $this->http_status = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
    $this->last_api_call = $api_url;
    curl_close($curl_handle);
    var_dump($this->http_status);
    var_dump($twitter_data);
    return $twitter_data;

And it returns {"errors":[{"code":53,"message":"Basic authentication is not supported"}]}

Can anyone figure it out what is the problem.开发者_StackOverflow Thanks in advance..


Exactly as it says. Twitter Basic auth, which is what you're doing, is no longer supported. You have to use OAuth instead. I recommend looking into this PHP library to easily work with Twitter via PHP:

https://github.com/abraham/twitteroauth


As the error message states, the problem is that basic authentication is not supported.

You need to use OAuth to authenticate with Twitter.

  • https://dev.twitter.com/pages/basic_to_oauth
  • https://dev.twitter.com/pages/auth
0

精彩评论

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