Sign In
Password Recovery Register

Unfollow people we're following on Twitter which are not following us back.

A script to unfollow people we're following on Twitter which are not following us back, using the Abraham Williams TwitterOAuth PHP library.

<?php

$oTwitter = new TwitterOAuth
(
	YOUR_TWITTER_APP_CONSUMER_KEY,
	YOUR_TWITTER_APP_CONSUMER_SECRET,
	YOUR_TWITTER_APP_OAUTH_TOKEN,
	YOUR_TWITTER_APP_OAUTH_SECRET
);

$aFollowing = $oTwitter->get('friends/ids');
$aFollowing = $aFollowing->ids;

$aFollowers = $oTwitter->get('followers/ids');
$aFollowers = $aFollowers->ids;

foreach( $aFollowing as $iFollowing )
{
	$isFollowing = in_array( $iFollowing, $aFollowers );

	echo "$iFollowing: ".( $isFollowing ? 'OK' : '!!!' )."<br/>";

	if( !$isFollowing )
	{
		$parameters = array( 'user_id' => $iFollowing );
		$status = $oTwitter->post('friendships/destroy', $parameters);
	}
}

?>

Comments

Login or Register to comment.


Embed Me!

Feel free to adjust iframe width and height according to your needs.

<iframe width="800px" 
        src="http://www.emoticode.net/embed/php/unfollow-people-were-following-on-twitter-which-are-not-following-us-back.html" 
        height="400px" 
        frameborder="0"> 
</iframe>

Here's how it will look like.