Free PHP Script to Mass Delete Twitter Friends, People You Follow

By Matt Dunlap on September 12th, 2009 27 comments
Don't forget to tweet this post for a chance to win a $100 BestBuy Gift Card
Time Left: | Details and Rules

twitterTwitter has changed…

Many early twitterers follow everyone that followed them. They are now having a hard time managing all their Twitter friends (people you follow) because of the twitter noise. Are you one of them? Do you need a way to delete them all?

Here is a simple PHP script that allows you to delete all of you friends in one big swoop or in tiny increments. It makes an array of all the people you follow, these cycles through them deleting each one until the limit that you set is reached. It will delete all, so if you want to save some users, you should make a list and then re-follow them when you are done deleting everyone. I didn’t add that feature to this script to keep it simple.

Installation:

  1. unzip the file and upload the PHP file to your webhost
  2. point your browser to the file, example http://yourdomain.com/delete_following.php
  3. enter your Twitter username, password and how many to delete.
  4. Click submit and let it go… Warning, it can take a long time to delete users if you delete thousands at a time.

Download the script here

Any questions or concerns, please leave a comment


My next post is going to be awesome... Subscribe to my feed so you don't miss it

Large RSS Feed Button


Previous Post Next Post

27 Responses to Free PHP Script to Mass Delete Twitter Friends, People You Follow

Singapore SEO Consultant
Comment added: 17 September, 2009 at 8:48 pm

I need a lot of followers at Twitter. If you want to delete them, could you transfer your followers to my account instead? LOL I wish you could have that kind of PHP script where you could transfer your followers to another account. :)

Matt Dunlap
Comment added: 17 September, 2009 at 9:09 pm

there are so many spam followers on twitter now, it just isn’t worth it. But, if you are looking to add followers you need to get an autofollow script. Maybe this weekend I’ll write one up

Sandra Vanhooser
Comment added: 18 September, 2009 at 10:31 am

Interesting thought. On a personal level this script would be perfect. I recently went through my Facebook and did just that. Deleted people I haven’t talked to in years! For business, I would have to agree with Singapore SEO Consultant because you never know who you will reach!

John
Comment added: 26 October, 2009 at 1:23 pm

(1) Checking out your script now.

(2) You can grap the animated whale for your next post about twitter.
http://twitpic.com/lb0ef

(3) Did you ever write the auto-follow script that you mention in the comments?

Yours
John

roberto
Comment added: 8 January, 2010 at 6:15 pm

Dude this is awsome I’m geting 300-500 folowers dayly just for folowing and then deleteing thrm and them it looks like if I was som1 famous

kalais
Comment added: 4 May, 2010 at 12:18 pm

The script didn’t work for me? Any suggestions? I got about a dozen of the lines of PHP code appear on the page when I navigated to the PHP file. The form was visible, so I filled it in, clicked submit. Nothin… Gutted.
Cheers
K

Matt Dunlap
Comment added: 4 May, 2010 at 1:37 pm

If the PHP code is visible, then you probably have an issue with your PHP tags. Make sure you are not prematurely exiting from your PHP code.
You should not see any PHP code displayed in your browser…

kalais
Comment added: 7 May, 2010 at 1:51 pm

I think I’ve figured out the issue. For this script to work, I would need to be running it on a server with a PHP rendering app running on it, correct? I was trying to run it from my open access FTP space. Duh!!
Question: is there any chance that it may break my WordPress blog install in any way if I upload and run it from somewhere within the WordPress folder directory??
Thanks
K

kalais
Comment added: 11 May, 2010 at 10:19 am

Sorted. Run it on the install with PHP and BAM!! it worked. I hope its not deriving anything it shouldn’t on the server, my tech will kill me if it is…
Thanks

Vincent
Comment added: 14 May, 2010 at 1:29 am

This script is not working for me. PHP page has something wrong in ‘class Twitter’ and the page stops there.

Matt Dunlap
Comment added: 14 May, 2010 at 8:48 am

Does the error display a line number? Can you please post the what the error says, I’ll look into it

Vincent
Comment added: 19 May, 2010 at 10:30 pm

I found what is the problem. It wasn’t working because php was 4.48 on 5.20 is working. Thanks

Matt Dunlap
Comment added: 20 May, 2010 at 10:26 am

Ah… I’m assuming it was the simple xml error. Glad you found the issue… not to everyone else, upgrade your PHP to 5.

Mass Twitter Follow Unfollow Script and App | Galaxark Blog
Comment added: 31 May, 2010 at 9:09 am

[...] Read More [...]

JW1
Comment added: 17 June, 2010 at 12:27 pm

Not working getting this error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c01/h08/mnt/8369/domains/xxxxxxx.com/html/delete_following.php on line 39

realhomeincomes
Comment added: 17 June, 2010 at 8:00 pm

Can you tell me what version PHP you are using? I have a feeling that you are using PHP4. I think that is the problem. It's easy to update PHP on most shared hosts…

Kalais
Comment added: 13 July, 2010 at 10:14 am

Weird. I managed to get the script working last time. Now I cant… Have tried it on my development environment and a number of php equipt servers.
The form appears, but its covered in php error gobble-de-gook. Shall I post it?
Thanks
K

Matt Dunlap
Comment added: 13 July, 2010 at 10:16 am

Sure post the error… One thing to note is that I believe twitter is moving to 100% oauth. That will definitely stop the script from working

Kalais
Comment added: 13 July, 2010 at 10:39 am

Cheers. Yea, I know they’re moving – what a shame. Terribly protectionistic.

error:
Let it run… Go grab a beer or something

set_user($_POST['username'], $_POST['password'], $_POST['how_many']); $res = $twitter->get_friends_ids_of_user(); for($count = 0; $count how_many_to_delete; $count++) { $out = $twitter->remove_user($res->id[$count]); if($out->id!=”) { echo “Deleted: “.$out->screen_name.”
“; } else { echo $out.”
“; } } ?> ‘>Click here to reload form if you want to delete some more people username = $username; $this->password = $password; $this->how_many_to_delete = $how_many; } function get_friends_ids_of_user() { //need to set the user before this will work $url = “http://twitter.com/friends/ids.xml”; $res = $this->hit_twitter($url); return $res; } function remove_user($username) { $url = “http://twitter.com/friendships/destroy/$username.xml”; $res = $this->hit_twitter($url, 1); return $res; } function hit_twitter($url, $post=0) { $host = $url; $username = $this->username; $password = $this->password; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_HEADER, 0); if($post) { curl_setopt($ch, CURLOPT_POST, $post); curl_setopt($ch, CURLOPT_POSTFIELDS ,$post_args); } $result = curl_exec($ch); if($out!=’xml’) { $result = @simplexml_load_string($result); } curl_close($ch); //print_r($result); return $result; } } ?>

Delete Twitter Followers
K

Matt Dunlap
Comment added: 13 July, 2010 at 10:48 am

Did you move it to a new server? is it possible that the PH is not allowing PHP short tags? I think it is outputting the PHP as text

Kalais
Comment added: 13 July, 2010 at 1:02 pm

I have tried it on the server we run a number of wordpress installs on. As well as a local development server. Neither worked.. Its odd, as it worked perfectly last time I used it… I dont think anything has been configured particularly diferently.
I will ask the chap who manages the servers, he may know. I will let you know.
Cheers

Matt Dunlap
Comment added: 13 July, 2010 at 1:04 pm

I think WordPress is really good at using the full php tags,bBut since I’m a lazy bastard, I not so strict

Kalais
Comment added: 13 July, 2010 at 1:11 pm

Cant see anything glaringly wrong with your code hehe.

Matt Dunlap
Comment added: 13 July, 2010 at 1:15 pm

All my code is licensed under the “Works for me…” license.

kalais
Comment added: 19 July, 2010 at 1:03 pm

Hi Matt. I never got your script to work again :(
This is stink, cos it is / was a good script for me.
I stayed up till silly hours last friday programming a macros to do it instead!! It works really well, let me know by email if you want it for the site, I will happily take a bit of kudos (and 4 hours of my life back).
K

kalais
Comment added: 19 July, 2010 at 1:04 pm

PS ‘Stink’ is a new zealand colloquialism… for rubbish, or bad or crappy etc.

Matt Dunlap
Comment added: 19 July, 2010 at 4:43 pm

I’m interested in checking out the macro… Does it refresh a browser page??? that’s cool because the API is easily traceable by Twitter

Post a Comment

Name:   
Email:   
Website:   
Comments:   
The Money Coach on Brian Timpone Responded to my Blockshopper.com Complaint Blog Post.
I respect that there is an open debate on this issue. The great thing about the internet is we have[...]
Thom Living Green on How to enable WordPress 3.0 to run multiple websites
I followed your instructions and it worked just like you said. I now have a secure wp 3.0 mu set up [...]
Brocha Weiss on Blog Math - Numbers don't lie when it comes to success.
Hi Matt, I agree when you said, if there's no traffic to your site there is no money. This is the[...]
RoC Skin Care Fan on Your most effective keywords are not in your blog post
Spot on advice about targeted keyword anchor text. Its amazing how many websites do not realise thi[...]
ACME Affiliates - Affiliate Networks on Take control of your blog advertising with OpenX Adserver
OpenX is a great solution for managing ads on any kind of site, not just a blog. The problem that mo[...]
Matt Dunlap on Jquery Anything Slider Plugin for WordPress Magazine Themes
That is so cool that you modified it and made it better... I'll fix my code, and make the changes W[...]
Powered By: Free Premium WordPress Theme | Copyright 2007 - 2010 mattdunlap.org Sitemap