Posted By

jamesming on 06/29/09


Tagged

curl php


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

irishsk
huynguye
xmartyxcorex
dinkan


Update your Facebook status with PHP CURL


 / Published in: PHP
 

URL: http://www.catswhocode.com/blog/10-awesome-things-to-do-with-curl

  1. <?PHP
  2. /*******************************
  3. * Facebook Status Updater
  4. * Christian Flickinger
  5. * http://nexdot.net/blog
  6. * April 20, 2007
  7. *******************************/
  8.  
  9. $status = 'YOUR_STATUS';
  10. $first_name = 'YOUR_FIRST_NAME';
  11. $login_email = 'YOUR_LOGIN_EMAIL';
  12. $login_pass = 'YOUR_PASSWORD';
  13.  
  14. $ch = curl_init();
  15. curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
  16. curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&login=Login');
  17. curl_setopt($ch, CURLOPT_POST, 1);
  18. curl_setopt($ch, CURLOPT_HEADER, 0);
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  21. curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
  22. curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  24. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
  25. curl_exec($ch);
  26.  
  27. curl_setopt($ch, CURLOPT_POST, 0);
  28. curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
  29. $page = curl_exec($ch);
  30.  
  31. curl_setopt($ch, CURLOPT_POST, 1);
  32. preg_match('/name="post_form_id" value="(.*)" \/>'.ucfirst($first_name).'/', $page, $form_id);
  33. curl_setopt($ch, CURLOPT_POSTFIELDS,'post_form_id='.$form_id[1].'&status='.urlencode($status).'&update=Update');
  34. curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
  35. curl_exec($ch);
  36. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: kekecmojca on November 3, 2010

Here is a working example of this snippet:

http://360percents.com/posts/php-curl-status-update-working-example/

You need to login to post a comment.