2009
09.12

So I have been banging my head off this all day and after browsing the internet forums it looks like everyone gave up around March of this year as far as logging into Facebook automatically and collecting data goes.

Then I started getting crazy and trying to get wget, lynx, links, elinks all to connect.

Then it hit me. To hell with the main site why not use the mobile site.

Connection with my command line browsers was a success

So I dove back into my PHP file and started CURL’ing away with the URL’s I found in the plain HTML source file of the mobile website and I got connection and it loaded my home page!

The I wondered if I could easily move about Facebook mobile and get the data I want (which is notes comments) and sure enough all I need to do is change CURLOPT_URL and exec it and it goes wherever I want.

Anyways it’s always nice to share so here is a rough example that will get you connected and output a page:

function connect_facebook() {
//Connect to data source and log in
$email = “you@email.com”;
$pass = “thepassword”;
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, “http://m.facebook.com/login.php?next=http%3A%2F%2Fm.facebook.com%2Fhome.php%3Fledac5e3a”);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, ‘cookiefile.txt’);
curl_setopt($ch, CURLOPT_COOKIEJAR, ‘cookiefile.txt’);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_USERAGENT, “Mozilla 4.0 (PHP ; CrazySpence Facebook Login Script 0.1 ; PERFECT EDITION”);
curl_setopt($ch, CURLOPT_REFERER,”http://m.facebook.com/”);
$post = array(“email” => $email, “pass” => $pass);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);

curl_exec($ch);

curl_setopt($ch, CURLOPT_URL,”http://m.facebook.com/notes.php”);
$download = curl_exec($ch);

print_r($download);
curl_close($ch);
}

If it doesn’t work for you……Oh well? I tried. Worked for me!

Facebook Comments

1 comment so far

Add Your Comment
  1. Is there a way to access the notes of a facebook fan page?
    Thank you!!!!

You must be logged in to post a comment.