Twitter REST Api 1.1 POST友谊/创建

时间:2012-11-20 04:10:54

标签: twitter access-token

我试图通过使用REST Api 1.1和PHP来实现Twitter friendships/create。但无论我如何尝试,它都会返回

stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [message] => Bad Authentication data
                    [code] => 215
                )
        )
)

我的代码是(使用亚伯拉罕库并将twitterauth改为v1.1)

$twitteroauth = new TwitterOAuth( $this->consumer_key, $this->consumer_secret, $oauth_token,     $oauth_token_secret);

$test_create = $twitteroauth->post('friendships/create',array('follow'=>true,'user_id'=>'2529416xx'));

print_r($test_create);exit;

3 个答案:

答案 0 :(得分:1)

我不是专家(我遇到同样的问题),但我认为你不应该更改oauth版本,因为它仍然是1.0a。可在此处https://dev.twitter.com/docs/api/1.1/overview#Authentication_required_on_all_endpoints和此处https://dev.twitter.com/docs/auth/authorizing-request找到更多信息。 更改仅在请求的URL中,例如:

https://api.twitter.com/1.1/statuses/mentions_timeline.json

答案 1 :(得分:0)

我也遇到了和你一样的问题。解决方案很简单:不要更改版本号(保持为1.0)并将主机更改为$ host =“https://api.twitter.com/1.1/”;

解决了我的问题!

答案 2 :(得分:0)

您可以尝试使用此代码 在这里your_screen_name你需要传递你的screen_name而不是your_user_id你需要传递你的用户ID

NSUserDefaults