-
-
Save wirespecter/d0baa98f7d6db32722059e00a576dc59 to your computer and use it in GitHub Desktop.
Twitter Bulk Follow
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
| <? | |
| function twitterSetStatus($user,$pwd,$screenName,$start,$end) { | |
| if (!function_exists("curl_init")) die("twitterSetStatus needs CURL module, please install CURL on your php."); | |
| $ch = curl_init(); | |
| // ------------------------------------------------------- | |
| // get login form and parse it | |
| $caCertsFile=getcwd().'/mobile.twitter.crt'; | |
| curl_setopt( $ch, CURLOPT_CAINFO, $caCertsFile ); | |
| curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com/session/new"); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); | |
| curl_setopt($ch,CURLOPT_SSLVERSION,3); | |
| curl_setopt($ch, CURLOPT_FAILONERROR, 1); | |
| curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); | |
| curl_setopt($ch, CURLOPT_TIMEOUT, 5); | |
| curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/cookies.txt"); | |
| curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/cookies.txt"); | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 "); | |
| $page = curl_exec($ch); | |
| $doc = new DomDocument; | |
| @$doc->loadHTML($page); | |
| $xpath = new DOMXpath($doc); | |
| $elements = $xpath->query("/html/body/div/div[2]/div/form/div/input"); | |
| if (!is_null($elements)) { | |
| foreach ($elements as $element) { | |
| $authenticity_token=($element->getAttribute('value')); | |
| } | |
| } | |
| $elements = $xpath->query("/html/body/div/div[2]/div/form"); | |
| if (!is_null($elements)) { | |
| foreach ($elements as $element) { | |
| $action=($element->getAttribute('action')); | |
| } | |
| } | |
| // ------------------------------------------------------- | |
| // make login and get home page | |
| $strpost = "authenticity_token=".urlencode($authenticity_token)."&username=".urlencode($user)."&password=".urlencode($pwd); | |
| curl_setopt($ch, CURLOPT_URL, $action); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost); | |
| $page = curl_exec($ch); | |
| // check if login was ok | |
| /* | |
| preg_match("/\<div class=\"warning\"\>(.*?)\<\/div\>/", $page, $warning); | |
| if (isset($warning[1])) return $warning[1]; | |
| $page = stristr($page,"<div class='tweetbox'>"); | |
| preg_match("/form action=\"(.*?)\"/", $page, $action); | |
| preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token); | |
| */ | |
| // ------------------------------------------------------- | |
| // send status update | |
| //echo $page | |
| curl_setopt($ch, CURLOPT_URL, "https://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=".$screenName); | |
| $json1 = json_decode(curl_exec($ch)); | |
| if(count($json1->ids)==0){ | |
| echo "No friend found!"; | |
| return 0; | |
| } | |
| $list=array_slice($json1->ids, $start, $end-$start); | |
| foreach( $list as $id){ | |
| curl_setopt($ch, CURLOPT_URL, "https://api.twitter.com/1/users/lookup.json?user_id=".$id."&include_entities=1"); | |
| $json2 = json_decode(curl_exec($ch)); | |
| curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com/".$json2[0]->screen_name); | |
| $page = curl_exec($ch); | |
| $doc = new DomDocument; | |
| @$doc->loadHTML($page); | |
| $xpath = new DOMXpath($doc); | |
| $elements = $xpath->query("/html/body/div/div[3]/div/div/form/div/input"); | |
| if (!is_null($elements)) { | |
| $i=0; | |
| $authenticityArray=array(); | |
| foreach ($elements as $element) { | |
| $authenticityArray[$i]=$element->getAttribute('value'); | |
| $i++; | |
| } | |
| } | |
| $elements = $xpath->query("/html/body/div/div[3]/div/div/form"); | |
| if (!is_null($elements)) { | |
| $i=0; | |
| $actionArray=array(); | |
| foreach ($elements as $element) { | |
| $actionArray[$i]=$element->getAttribute('action'); | |
| $i++; | |
| } | |
| } | |
| $ar = array("authenticity_token" => $authenticityArray[0], "commit"=>'Follow'); | |
| $data = http_build_query($ar); | |
| curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com".$actionArray[0]); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
| $page = curl_exec($ch); | |
| echo "Followed : ".$json2[0]->screen_name."<br/>"; | |
| } | |
| return true; | |
| } | |
| ?> | |
| <? | |
| if($_POST){ | |
| unlink(dirname(__FILE__)."\cookies.txt"); | |
| twitterSetStatus( $_POST["username"],$_POST["password"],$_POST["screenname"],$_POST["start"],$_POST["end"]); | |
| } | |
| ?> | |
| <form method="post"> | |
| <h2>Auth</h2> | |
| <table> | |
| <tr> | |
| <td>User Name:</td><td><input name="username" type="text" value="BullyEnt1" /></td> | |
| </tr> | |
| <tr> | |
| <td> | |
| Password : | |
| </td> | |
| <td> | |
| <input name="password" type="text" value="steadfast1" /><br/> | |
| </td> | |
| </tr> | |
| <table> | |
| <h2> Search</h2> | |
| <table> | |
| <tr> | |
| <td> | |
| Screen Name:</td> | |
| <td><input name="screenname" type="text" value="<?php echo isset($_POST["screenname"])?$_POST["screenname"]:"BankyW"?>" /></td> | |
| </tr> | |
| <tr> | |
| <td> | |
| Start :</td><td><input name="start" type="text" value="<?php echo isset($_POST["start"])?$_POST["start"]:0 ?>" /></td> | |
| </tr> | |
| <tr><td> | |
| End :</td> <td><input name="end" type="text" value="<?php echo isset($_POST["end"])?$_POST["end"]:140 ?>" /></td> | |
| </tr> | |
| </table> | |
| <br/> | |
| <input type="submit" value="Submit"> | |
| </form> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment