Thursday, January 12, 2012

update Facebook status using php

// 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);

Send Message to Yahoo! Messenger from PHP

  // last update: July 20, 2010

  // get home page of yahoo mobile
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, "http://us.m.yahoo.com/w/bp-messenger");
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_ENCODING, "");
  curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14,52; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)");
  curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . '/cookies_yahoo_messenger.cookie');
  $curlData = curl_exec($curl);
  curl_close($curl);