Created
May 15, 2011 03:54
-
-
Save dmpatierno/972873 to your computer and use it in GitHub Desktop.
unfollow all users on tumblr
This file contains hidden or 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 | |
$cookie = "<insert cookies>"; | |
$token = null; | |
do { | |
$users = get_users(); | |
foreach ($users as $user) | |
unfollow($user); | |
} while (count($users)); | |
echo "done\n"; | |
function get_users($page = 1) { | |
global $cookie, $token; | |
$url = "http://www.tumblr.com/following"; | |
$ch = curl_init($url); | |
curl_setopt_array($ch, array( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_COOKIE => $cookie | |
)); | |
$response = curl_exec($ch); | |
preg_match_all('/unfollow_button_[^"]+" data-name="([^"]+)" data-formkey="([^"]+)"/', $response, $m); | |
$token = $m[2][0]; | |
return $m[1]; | |
} | |
function unfollow($user) { | |
global $cookie, $token; | |
$url = 'http://www.tumblr.com/svc/unfollow'; | |
$ch = curl_init($url); | |
curl_setopt_array($ch, array( | |
CURLOPT_COOKIE => $cookie, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => "form_key={$token}&data[tumblelog]={$user}&data[source]=FOLLOW_SOURCE_FOLLOWING_PAGE" | |
)); | |
$response = curl_exec($ch); | |
echo "unfollow {$user}\n"; | |
} |
It's a PHP script. You'll need to set your cookie on line 3 and run it from the command line.
Couple more questions-
what's a cookie?
command line = terminal?
Hi dmpatierno,
I'm running this from my server. What do I put in line 3? Do I need to put in a cookie from Tumblr? It puts 11 cookies on my browser. Which one should I put?
Help much appreciated.
Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I use this in chrome?