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 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题