douran9707 2015-10-31 13:26
浏览 19
已采纳

取消关注Twitter配置文件PHP脚本不起作用

I'm not able to unfollow accounts. The code is returning the account details of user whom I want to unfollow. Application is created by Account A, with read/write/Access Direct Messages. I have logged in with a Account B, authenticated and returned back. Using below code I want to unfollow.

$key=$twitter_id_whom_i_want_to_unfollow; 

$settings = array(
    'oauth_access_token' => YOUR_ACCESS_TOKEN,
    'oauth_access_token_secret' => YOUR_ACCESS_TOKEN_SECRET,
    'consumer_key' => YOUR_CONSUMER_KEY,
    'consumer_secret' => YOUR_CONSUMER_SECRET
);
$requestMethod = 'POST';
$postfields = array(
        'user_id' => $key
            );
$url = 'https://api.twitter.com/1.1/friendships/destroy.json'; /*Remove that user from friends*/
$twitter = new TwitterAPIExchange($settings);
$profile=$twitter->buildOauth($url, $requestMethod)
         ->setPostfields($postfields)
         ->performRequest();
$profile=json_decode($profile); 
echo '<pre>';print_r($profile);

This prints $twitter_id_whom_i_want_to_unfollow account details. Not able to understand how to deal with it. I'm developing a web app like crowdfire

If I use same script to unfollow from $twitter_id_whom_i_want_to_unfollow account, it works, but not from any other account.

  • 写回答

1条回答 默认 最新

  • douwei1921 2015-12-30 09:51
    关注

    Ok Found the solution. The above script is perfectly working, issue was with the access tokens, which were not being saved. Its fine now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器