Jump to content

Facebook pages status update


$php_mysql$

Recommended Posts

hi i found this on google. how could i use it, could someone give example of usage?

 

 

here is the class

 

//
// change Facebook status with curl
// Thanks to Alste (curl stuff inspired by nexdot.net/blog)
function setFacebookStatus($status, $login_email, $login_pass, $debug=false) {
//CURL stuff
//This executes the login procedure
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=' . urlencode($login_email) . '&pass=' . urlencode($login_pass) . '&login=' . urlencode("Log in"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//make sure you put a popular web browser here (signature for your web browser can be retrieved with 'echo $_SERVER['HTTP_USER_AGENT'];'
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");
curl_exec($ch);

//This executes the status update
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
$page = curl_exec($ch);

//echo htmlspecialchars($page);

curl_setopt($ch, CURLOPT_POST, 1);
//this gets the post_form_id value
preg_match("/input type=\"hidden\" name=\"post_form_id\" value=\"(.*?)\"/", $page, $form_id);
preg_match("/input type=\"hidden\" name=\"fb_dtsg\" value=\"(.*?)\"/", $page, $fb_dtsg);
preg_match("/input type=\"hidden\" name=\"charset_test\" value=\"(.*?)\"/", $page, $charset_test);
preg_match("/input type=\"submit\" class=\"button\" name=\"update\" value=\"(.*?)\"/", $page, $update);

//we'll also need the exact name of the form processor page
//preg_match("/form action=\"(.*?)\"/", $page, $form_num);
//sometimes doesn't work so we search the correct form action to use
//since there could be more than one form in the page.
preg_match_all("#<form([^>]*)>(.*)</form>#Ui", $page, $form_ar);
for($i=0;$i<count($form_ar[0]);$i++)
	if(stristr($form_ar[0][$i],"post_form_id")) preg_match("/form action=\"(.*?)\"/", $page, $form_num); 	

$strpost = 'post_form_id=' . $form_id[1] . '&status=' . urlencode($status) . '&update=' . urlencode($update[1]) . '&charset_test=' . urlencode($charset_test[1]) . '&fb_dtsg=' . urlencode($fb_dtsg[1]);
if($debug) {
	echo "Parameters sent: ".$strpost."<hr>";
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost );

//set url to form processor page
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com' . $form_num[1]);
curl_exec($ch);

if ($debug) {
	//show information regarding the request
	print_r(curl_getinfo($ch));
	echo curl_errno($ch) . '-' . curl_error($ch);
	echo "<br><br>Your Facebook status seems to have been updated.";
}
//close the connection
curl_close($ch);
}

 

and

 

define (‘FACEBOOK_EMAIL_LOGIN’, ‘xxxxx’);

define (‘FACEBOOK_PASSWORD’, ‘yyyyy’);

 

define (‘FACEBOOK_DEBUG’, false);

 

require_once ‘includes / minibots.class.php’;

$ M = new Minibots ();

 

if (isset ($ _GET ['status'])) (

$ M-> setFacebookStatus ($ _GET ['status'], FACEBOOK_EMAIL_LOGIN, FACEBOOK_PASSWORD, FACEBOOK_DEBUG);

)

 

if (isset ($ _GET ['post'])) (

$ M-> postToFacebookPage ($ _GET ['post'], ‘wall.php’ FACEBOOK_EMAIL_LOGIN, FACEBOOK_PASSWORD, FACEBOOK_DEBUG);

)

 

how could one use this?

Link to comment
Share on other sites

ok i got this one people says it works but when i run it, in my browaer i get like this

 

[+] Sending GET request to: http://m.facebook.com/ [+] Sending POST data to: [-] charset_test= [-] lsd= [-] email=useremail%40yahoo.com [-] pass=userpass [-] login=Log+in [+] Sending POST data to: http://m.facebook.com [-] charset_test= [-] fb_dtsg= [-] post_form_id= [-] status=It+works+%3A%29 [-] update=Share

 

<?php
/*
PHP Curl status update script by http://360percents.com
Please use for educational and legal purposes
*/
function update($email, $pass, $status){

/*========================================================================
1. GET: http://m.facebook.com/
Parse the webpage and collect login parameters
(chartest, lsd, formaction).
========================================================================*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_URL,"http://m.facebook.com/");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$fbhome = curl_exec ($ch); //execute the curl command

echo "\n[+] Sending GET request to: http://m.facebook.com/\n\n";

preg_match("/<form action=\"(.*)\" method=\"post\">/U", $fbhome, $formaction);
urlencode(preg_match("/<input type=\"hidden\" name=\"charset_test\" value=\"(.*)\" \/>/U", $fbhome, $chartest));
preg_match("/<input type=\"hidden\" name=\"lsd\" value=\"(.*)\" autocomplete=\"off\" \/>/U", $fbhome, $lsd);

curl_close ($ch); //cleanup
unset($fbhome);
unset($ch);
/*========================================================================
2. LOGIN: POST to facebook login form (formaction) with previously
collected parameters lsd, chartest, email, pass and login.
Collect parameters from the form which updates status 
(formaction, chartest, dtsg, formid).
========================================================================*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_URL, $formaction[1]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "charset_test=".$chartest[1]."&lsd=".$lsd[1]."&email=$email&pass=$pass&login=Log+in");

$loggedin = curl_exec ($ch); //execute the curl command

echo "[+] Sending POST data to: ".html_entity_decode(urldecode($formaction[1]))."\n[-] charset_test=".$chartest[1]."\n[-] lsd=".$lsd[1]."\n[-] email=$email\n[-] pass=$pass\n[-] login=Log+in\n\n";

preg_match("/<form action=\"(.*)\" method=\"post\">/U", $loggedin, $formaction);
urlencode(preg_match("/<input type=\"hidden\" name=\"charset_test\" value=\"(.*)\" \/>/U", $loggedin, $chartest));
preg_match("/<input type=\"hidden\" name=\"fb_dtsg\" value=\"(.*)\" autocomplete=\"off\" \/>/U", $loggedin, $dtsg);
preg_match("/<input type=\"hidden\" name=\"post_form_id\" value=\"(.*)\" \/>/U", $loggedin, $formid);

//cleanup
curl_close ($ch);
unset($loggedin);
unset($ch);
/*========================================================================
3. UPDATE STATUS: Use previously collected form data to send a post query
which will update our status.
========================================================================*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com'.$formaction[1]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "charset_test=".$chartest[1]."&fb_dtsg=".$dtsg[1]."&post_form_id=".$formid[1]."&status=$status&update=Share");

$buf2 = curl_exec ($ch); //execute the curl command

echo "[+] Sending POST data to: http://m.facebook.com".html_entity_decode($formaction[1])."\n[-] charset_test=".$chartest[1]."\n[-] fb_dtsg=".$dtsg[1]."\n[-] post_form_id=".$formid[1]."\n[-] status=$status\n[-] update=Share\n\n";

//cleanup
curl_close ($ch);
unset($ch);
if(strlen($buf2)>0){echo "[+] Status update response:$buf2\n\n";}//errors will probably appear here if it fails 
unset($buf2);
/*========================================================================
End funtion update and return.
========================================================================*/
return 0;
}

//Call the update function with your email, password and status parameters.
$status = 'It works ';
update(urlencode('your@email.com'),'yourpassword',urlencode($status));

?>

 

what could be wrong?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.