Free Twitter Web Poster using Curl/PHP

mataff

Junior Member
Joined
Sep 21, 2008
Messages
139
Reaction score
55
Just wanted to give back to the forum as it's been an excellent resource over the years. I don't post often but I'm always scanning through the wealth of info available here.

Anyway, I've rewritten the script to display curl sequentially for posters who are still a bit iffy on using curl. In the beginning I found it easier this way vs all wrapped within a single function.

REMEMBER to change the hxxp to http in all of the links. Seems I'm still not able to post links in the forum.

PHP:
<?php
set_time_limit(0);
$user = "XXXXXXXX"; 
$pass = "XXXXXXXX"; 
$agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR";
$timeout = 30; 
$cookie_file_path = "cookie.txt"; 

//$tinyurl = GrabTinyUrl("hxxp://example.com");  //UNCOMMENT TO ENABLE TINYURL FUNCTION
if (isset($tinyurl)) {
      $message = "XXXXXXXXXXXXXXXXXXXXXXX " . $tinyurl;
} else {
      $message = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$url1 = "hxxp://twitter.com/login"; 
$refer1 = ""; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_REFERER, $refer1);
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);

preg_match ('/(?s)\<input name="authenticity_token" value="(.*?)" type="hidden"\/\>/',$result, $authtoken); 

if (!empty($authtoken)) {
	$post = 'authenticity_token=' . trim($authtoken[1]) . '&authenticity_token=' . trim($authtoken[1]) .
		'&return_to_ssl=false&redirect_after_login=&session' . urlencode("[username_or_email]") . 
		'=' . $user . '&'  . urlencode("session[password]") . '=' . $pass . '&commit=' . urlencode("Sign In"); 
			
	$url2 = "hxxps://twitter.com/sessions";
	curl_setopt($ch, CURLOPT_USERAGENT, $agent);
	curl_setopt($ch, CURLOPT_URL, $url2);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_REFERER, $url1);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
	curl_setopt($ch, CURLOPT_FAILONERROR,false);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,  true);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_POST,  true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
	$result = curl_exec($ch);
}
$check = CaptchaCheck($result); 

if ($check == "no") {
	
	preg_match ('/(?s)\<input name="authenticity_token" value="(.*?)" type="hidden"\/\>/',$result, $authtoken); 
	
	$post = 'authenticity_token=' . trim($authtoken[1]) . '&status=' . urlencode($message) .
		 '&twttr=true&return_rendered_status=true&lat=&lon=&place_id=&display_coordinates=false'; 
			
	$url3 = "hxxp://twitter.com/status/update";
	curl_setopt($ch, CURLOPT_USERAGENT, $agent);
	curl_setopt($ch, CURLOPT_URL, $url3);
	curl_setopt($ch, CURLOPT_REFERER, $url2);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
	curl_setopt($ch, CURLOPT_FAILONERROR,false);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,  true);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_POST,  true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
	curl_exec($ch);

	echo 'Message Posted - ' . $message . "\n";
} else {
	echo "Captcha Found"; 
}
	curl_close($ch); 

function CaptchaCheck($result) {

	$capcheck = stripos($result, "recaptcha");
	
	if ($capcheck !== false) {
	    return "yes";
	} else {
	     return "no"; 
	}	
}

function GrabTinyUrl($url) {
		
	$tiny_url = "hxxp://************************//api-create.php?url=" . $url;
	$timeout = 30; 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_REFERER, '');
	curl_setopt($ch, CURLOPT_URL, $tiny_url);
	curl_setopt($ch, CURLOPT_FAILONERROR, true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$result = curl_exec($ch);
	curl_close($ch); 
		
	return trim($result); 
				
}

?>

I tested it before posting and it worked perfectly.

Currently I've been using this to simulate a real user based around a few CPA ads that have been performing well of late.

I scrape forum comments (to make life easier use google discussions search) based around those keywords and randomize the posting times. I also scan recent twitter posts based on my keywords list and either sending a direct message to the user or follow them if they are within the allowed country of where the CPA specificities.

Following and getting followed from twitter users happened a heck of a lot quicker when they see "Posted via Web" over anything else.

ENJOY :D
 
Last edited:
can you use multiple accs for this?

and some of your links on your script have been censored.
 
can you use multiple accs for this?

Definitely. Just make sure you rotate your proxies within the script along with the users and your fine or the easiest way is have one script per user with proxies hard coded in and run them all simultaneously.

I use a database and pull everything from there but any other method is fine.

and some of your links on your script have been censored.

Only link that censored is the tinyurl link.
 
Last edited:
I tried this script.
i got the answer:
Message Posted - xxxx

But the message doesn't appear on twitter?
Do you have any idea.?
 
Back
Top