如何使用php更改facebook状态

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用php更改facebook状态相关的知识,希望对你有一定的参考价值。

Changing Facebook Status with php, download the Mini Bot PHP class from the blog http://www.barattalo.it
  1. //
  2. // change Facebook status with curl
  3. // Thanks to Alste (curl stuff inspired by nexdot.net/blog)
  4. public function setFacebookStatus($status, $login_email, $login_pass) {
  5. $debug = false;
  6. //CURL stuff
  7. //This executes the login procedure
  8. $ch = curl_init();
  9. curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
  10. curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=' . urlencode($login_email) . '&pass=' . urlencode($login_pass) . '&login=' . urlencode("Log in"));
  11. curl_setopt($ch, CURLOPT_POST, 1);
  12. curl_setopt($ch, CURLOPT_HEADER, 0);
  13. //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  15. curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
  16. curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. //make sure you put a popular web browser here (signature for your web browser can be retrieved with 'echo $_SERVER['HTTP_USER_AGENT'];'
  19. 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");
  20. curl_exec($ch);
  21.  
  22. //This executes the status update
  23. curl_setopt($ch, CURLOPT_POST, 0);
  24. curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
  25. $page = curl_exec($ch);
  26.  
  27. curl_setopt($ch, CURLOPT_POST, 1);
  28. //this gets the post_form_id value
  29. preg_match("/input type="hidden" name="post_form_id" value="(.*?)"/", $page, $form_id);
  30. //we'll also need the exact name of the form processor page
  31. preg_match("/form action="(.*?)"/", $page, $form_num);
  32.  
  33. curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id=' . $form_id[1] . '&status=' . urlencode($status) . '&update=' . urlencode("Update status"));
  34. //set url to form processor page
  35. curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com' . $form_num[1]);
  36. curl_exec($ch);
  37.  
  38. if ($debug) {
  39. //show information regarding the request
  40. echo curl_errno($ch) . '-' . curl_error($ch);
  41. echo "<br><br>Your Facebook status seems to have been updated.";
  42. }
  43. //close the connection
  44. curl_close($ch);
  45. }

以上是关于如何使用php更改facebook状态的主要内容,如果未能解决你的问题,请参考以下文章

PHP 如何用PHP更改Facebook状态

使用PageChangeListener动态更改选项卡图标的颜色

方向/配置更改后如何维护 ListView 片段状态?

通过底部导航栏更改片段时恢复片段状态

php 在Yoast SEO中更改或删除OpenGraph输出的代码片段。此代码中有多个代码段。

如何更改 viewpager 中每个片段的点指示器(活动和非活动)的颜色?