2012-11-20 106 views
2

我試圖通過使用REST Api 1.1和PHP實現Twitter friendships/create。但我無論怎麼嘗試過與Twitter REST Api 1.1 POST友誼/創建

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; 

回答

0

我有像你同樣的問題也。解決方案很簡單:不更改版本號(保持1.0)並將主機更改爲$ host =「https://api.twitter.com/1.1/」;

解決了我的!

0

your_screen_name你需要通過你的SCREEN_NAME和替代your_user_id你需要通過你的用戶ID你可以試試這個代碼 這裏

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['token'] , $_SESSION['token_secret']); 

$connection->post('friendships/create', array('screen_name'=>'your_screen_name','user_id'=>'your_user_id','follow'=>'true'));