Created
March 26, 2012 21:14
-
-
Save masbog/2209767 to your computer and use it in GitHub Desktop.
Who Not Following Back You algorith on Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('twitteroauth/twitteroauth.php'); | |
define('CONSUMER_KEY', ''); | |
define('CONSUMER_SECRET', ''); | |
define('ACCESS_TOKEN', ''); | |
define('ACCESS_TOKEN_SECRET', ''); | |
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |
$twitter->host = "https://api.twitter.com/1/"; | |
$result = $twitter->get('followers/ids', array('screen_name' => 'your_name')); | |
$followerId = $result->{'ids'}; | |
$twitter1 = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |
$result1 = $twitter1->get('friends/ids', array('screen_name' => 'your_name')); | |
$followingId = $result1->{'ids'}; | |
$x = 0; | |
echo '<div id="output" class="clearfix"><ul class="twitter-users">'; | |
for($i=0;$i<count($followingId);$i++) | |
{ | |
if (in_array($followingId[$i], $followerId)) { | |
//do nothing | |
}else | |
{ | |
$urlData = 'https://api.twitter.com/1/users/show.json?id='.$followingId[$i]; | |
$data = json_decode(file_get_contents($urlData)); | |
//echo $data->{'screen_name'}." not following you.<br>"; | |
echo '<li>'; | |
echo '<a href="http://twitter.com/'.$data->{'screen_name'}.'" class="avatar" target="_blank"><img src="'.$data->{'profile_image_url'}.'" height="48" width="48"></a>'; | |
echo '<input name="user-"'.$x.' value="'.$data->{'screen_name'}.'" type="checkbox">'; | |
echo '<a href="http://twitter.com/'.$data->{'screen_name'}.'" class="screen-name" target="_blank">'.$data->{'screen_name'}.'</a>'; | |
echo '<div class="is-friend">you follow them</div>'; | |
echo '<div class="action"><a href="javascript:void(0);" onclick="action(this, "unfollow", "'.$data->{'screen_name'}.'"); return false;">unfollow</a></div>'; | |
echo '</li>'; | |
$x = $x + 1; | |
} | |
} | |
echo '</ul></div>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now working