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.
Ok Found the solution. The above script is perfectly working, issue was with the access tokens, which were not being saved. Its fine now.