Hack Forums
[PHP] Twitter Mass Unfollow (reverse the Mass Follower script) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Twitter Mass Unfollow (reverse the Mass Follower script) (/showthread.php?tid=2951434)



Twitter Mass Unfollow (reverse the Mass Follower script) - salventura - Oct 17, 2012

I have a script where you can load your username:pass list of all your twitter accounts and then put in the account that you wish for all of the users to follow.

Is there a way to reverse that script? I need a script, where I can load my username:pass list and put in the account so all the users will unfollow that user.

Any help would be appreciate.


* - Linux. - Oct 17, 2012

I can reverse it PM with the script, and I will do it gladly.


* - salventura - Oct 17, 2012

(Oct 17, 2012 07:23 PM)Crypto™ Wrote:  I can reverse it PM with the script, and I will do it gladly.

Thanks Crypto, I pm the script to you. I appreciate your help.


* - Linux. - Oct 17, 2012

(Oct 17, 2012 07:32 PM)salventura Wrote:  Thanks Crypto, I pm the script to you. I appreciate your help.

I tired no success. Sorry, again. I may keep trying.


* - salventura - Oct 17, 2012

No problem Crypto, I still appreciate you taking the time to look at it.

If anybody else has any ideas or thoughts please let me know.


* - Vlad1k - Oct 17, 2012

I can do it for you. PM me the script.


* - salventura - Oct 17, 2012

(Oct 17, 2012 08:10 PM)Vlad1k Wrote:  I can do it for you. PM me the script.

Thank you for your time Vlad1k, I pm'd all the info to you.


* - ComponY - Oct 17, 2012

I would like to get this script as well! Let me know if I can get it once it's done for you!


* - Kabyle - Oct 18, 2012

PHP Code

<?php
    set_time_limit
(false);
    
error_reporting(false);    
    if (isset(
$_POST["perfis"])) {
  
$logins = explode("\n", $_POST["perfis"]);
  
$follow = $_POST["follow"];
  
$contar = count($logins);
  for(
$i = 0; $i <= $contar; $i++) {
    if (!(
preg_match("/[a-zA-Z0-9]+/i", $logins[$i]))) {
    continue;
    }
    
$data = explode(":", $logins[$i]);
    if (
$data[0][0] == "@")
    
$data[0] = str_replace("@", "", $data[0]);
    
$ch = curl_init();
    
curl_setopt_array($ch,
    array(
    
CURLOPT_URL => "http://api.twitter.com/1/friendships/create/{$follow}.xml",
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_SSL_VERIFYPEER => 0,
    
CURLOPT_COOKIE => null,
    
CURLOPT_HEADER => true,
    
CURLOPT_NOBODY => false,
    
CURLOPT_POSTFIELDS => "&follow=true",
    
CURLOPT_USERPWD => trim($data[0]) . ":" . trim($data[1])
    )
    );

  
$ret = curl_exec($ch);
  if (
preg_match("/Unauthorized/i", $ret)) {
    print 
"<b><font style='color: red;'>".$data[0]." - Error</font></b><br />";
    
flush();
    
ob_flush();
    
sleep(1);
  } else {
    print 
"<b><font style='color: green;'>".$data[0]." - Success</font></b><br />";
    
//include("../loop.php");include("config.php");
    
flush();
    
ob_flush();
    
sleep(1);
  }
    }
}

?>

Is it this one?


* - salventura - Oct 18, 2012

(Oct 18, 2012 04:28 AM)Kabyle Wrote:  
PHP Code

<?php
    set_time_limit
(false);
    
error_reporting(false);    
    if (isset(
$_POST["perfis"])) {
  
$logins = explode("\n", $_POST["perfis"]);
  
$follow = $_POST["follow"];
  
$contar = count($logins);
  for(
$i = 0; $i <= $contar; $i++) {
    if (!(
preg_match("/[a-zA-Z0-9]+/i", $logins[$i]))) {
    continue;
    }
    
$data = explode(":", $logins[$i]);
    if (
$data[0][0] == "@")
    
$data[0] = str_replace("@", "", $data[0]);
    
$ch = curl_init();
    
curl_setopt_array($ch,
    array(
    
CURLOPT_URL => "http://api.twitter.com/1/friendships/create/{$follow}.xml",
    
CURLOPT_RETURNTRANSFER => 1,
    
CURLOPT_SSL_VERIFYPEER => 0,
    
CURLOPT_COOKIE => null,
    
CURLOPT_HEADER => true,
    
CURLOPT_NOBODY => false,
    
CURLOPT_POSTFIELDS => "&follow=true",
    
CURLOPT_USERPWD => trim($data[0]) . ":" . trim($data[1])
    )
    );

  
$ret = curl_exec($ch);
  if (
preg_match("/Unauthorized/i", $ret)) {
    print 
"<b><font style='color: red;'>".$data[0]." - Error</font></b><br />";
    
flush();
    
ob_flush();
    
sleep(1);
  } else {
    print 
"<b><font style='color: green;'>".$data[0]." - Success</font></b><br />";
    
//include("../loop.php");include("config.php");
    
flush();
    
ob_flush();
    
sleep(1);
  }
    }
}

?>

Is it this one?

Yes that is the one to follow, I need to make that unfollow. I've tried changing various lines in the script but have not had no luck.


* - Linux. - Oct 18, 2012

I think you need to change the twitter api usage, not so much the code but the functions being used.


* - salventura - Oct 18, 2012

(Oct 18, 2012 12:47 PM)Crypto™ Wrote:  I think you need to change the twitter api usage, not so much the code but the functions being used.

Code
CURLOPT_URL => "http://api.twitter.com/1/friendships/create/{$follow}.xml",

I believe to unfollow the line should read

Code
CURLOPT_URL => "http://api.twitter.com/1/friendships/destroy

but I'm not sure what else follows.

I've tried changing different lines that read follow to unfollow, etc.. Spent a few hours on it, until my head started to hurt. I only half way know what I'm doing... lol

If I knew more about what I was doing I'm pretty sure it could be made in a short amount of time.


* - Linux. - Oct 18, 2012

(Oct 18, 2012 01:01 PM)salventura Wrote:  [phpcode] CURLOPT_URL => "http://api.twitter.com/1/friendships/create/{$follow}.xml", [/phpcode]

One moment, I think I know how to fix it :D I will change the function.


Here I found the link for it, this should work.

https://dev.twitter.com/docs/api/1/post/friendships/destroy
I will write some code for it one moment.


Try this code and tell me if it works or not if it does then great.

PHP Code

<?php 
CURLOPT_URL 
=> "http://api.twitter.com/1/friendships/destroy/{$follow}.xml", 



* - salventura - Oct 18, 2012

(Oct 18, 2012 01:02 PM)Crypto™ Wrote:  Try this code and tell me if it works or not if it does then great.

PHP Code

<?php 
CURLOPT_URL 
=> "http://api.twitter.com/1/friendships/destroy/{$follow}.xml", 

Just changing that line did not work, I tried changing that line by itself, as well as changing it to that, and changing some of the other lines with it. No luck as of yet. Once again I appreciate your time.