function InicioSesionN($username,$password){ //si la cookie existe es porque ya se ha iniciado sesion//si inicias sesion repetidas ocaciones en fb te baneaif(file_exists("cookies_facebook.cookie")){$ch = curl_init ();curl_setopt ( $ch, CURLOPT_URL, "http://m.facebook.com/home.php" );curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt ( $ch, CURLOPT_COOKIEFILE, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_COOKIEJAR, getcwd () . '/cookies_facebook.cookie' );curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");return curl_exec ( $ch );curl_close ( $ch ); }else{// script name: login_to_facebook.php// coder: Sony AK Knowledge Center - www.sony-ak.com///Obtenemos wl codigo fuente de la paggina de facebook y extreremos unos caracteres esenciales para iniciar sesion$ch = curl_init ();curl_setopt ( $ch, CURLOPT_URL, "http://www.facebook.com" );curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt ( $ch, CURLOPT_COOKIEJAR, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );$chData = curl_exec ( $ch );curl_close ( $ch );$charsetTest = substr ( $chData, strpos ( $chData, "name=\"charset_test\"" ) );$charsetTest = substr ( $charsetTest, strpos ( $charsetTest, "value=" ) + 7 );$charsetTest = substr ( $charsetTest, 0, strpos ( $charsetTest, "\"" ) );$locale = substr ( $chData, strpos ( $chData, "name=\"locale\"" ) );$locale = substr ( $locale, strpos ( $locale, "value=" ) + 7 );$locale = substr ( $locale, 0, strpos ( $locale, "\"" ) );$lsd = substr ( $chData, strpos ( $chData, "name=\"locale\"" ) );$lsd = substr ( $lsd, strpos ( $lsd, "value=" ) + 7 );$lsd = substr ( $lsd, 0, strpos ( $lsd, "\"" ) );/////Una vez que tenemos esos valores los usamos para iniciar sesion$ch = curl_init ();curl_setopt ( $ch, CURLOPT_URL, "https://login.facebook.com/login.php?login_attempt=1" );curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt ( $ch, CURLOPT_POST, 1 );curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );curl_setopt ( $ch, CURLOPT_POSTFIELDS, "charset_test=" . $charsetTest . "&locale=" . $locale . "&non_com_login=&email=" . $username . "&pass=" . $password . "&charset_test=" . $charsetTest . "&lsd=" . $lsd );curl_setopt ( $ch, CURLOPT_COOKIEFILE, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_COOKIEJAR, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );curl_exec ( $ch );// ya iniciada la sesion podemos navegar en cualquier pagina por default iremos a homecurl_setopt($ch, CURLOPT_POST, 0);curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');return curl_exec($ch);curl_close ( $ch );}}
<?phpinclude("funciones.php");//Tus datos de logueo$login_email = '';$login_pass = '';$inicio=InicioSesionN($login_email,$login_pass);?>
// recibimos dos parametros, el nombre del archivo que creara y el codigo fuentefunction CreaHtmlLogs($nombreArchivo,$codigo){//abrimos el archivo si no existe lo crea $file=fopen("".$nombreArchivo.".html","w+"); //escribimos en el lo que le pasemos como parametro fwrite($file,$codigo); //cerramos fclose($file);}
<?phpinclude("funciones.php");//Tus datos de logueo$login_email = '';$login_pass = '';$inicio=InicioSesionN($login_email,$login_pass);CreaHtmlLogs("index",$inicio);?>
// recibe como parametro el path o achivo a abrir y regresa el codigo fuentefunction abrirPagina($path){$ch = curl_init();curl_setopt ( $ch, CURLOPT_URL, 'http://m.facebook.com/'.$path );curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt ( $ch, CURLOPT_COOKIEFILE, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_COOKIEJAR, getcwd () . '/cookies_facebook.cookie' );curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");return curl_exec($ch);curl_close ( $ch );}
<?phpinclude("funciones.php");//Tus datos de logueo$login_email = '';$login_pass = '';$inicio=InicioSesionN($login_email,$login_pass);/*CreaHtmlLogs("index",$inicio);$notificaciones=abrirPagina('notifications.php');CreaHtmlLogs("notificaciones",$notificaciones);$mensajes=abrirPagina('messages/');CreaHtmlLogs("mensajes",$mensajes);?>
function extraerVariablesMuro($codigo){/*<input type="hidden" name="fb_dtsg" value="" autocomplete="off" /><input type="hidden" name="charset_test" value="" /><input type="hidden" autocomplete="off" name="privacy" value="" /><form method="post" id="composer_form" action="">*/preg_match("/type=\"hidden\" name=\"fb_dtsg\" value=\"(.*?)\" autocomplete=\"off\"/",$codigo,$fb_dtsg);preg_match("/type=\"hidden\" name=\"charset_test\" value=\"(.*?)\"/",$codigo,$charset_test);preg_match("/method=\"post\" id=\"composer_form\" action=\"(.*?)\"/",$codigo,$action);/* Este valor solo no los muestra cuando estamos en nuestro muro, en muro de amigos no! */preg_match("/type=\"hidden\" autocomplete=\"off\" name=\"privacy\" value=\"(.*?)\"/",$codigo,$privacy);return array ($fb_dtsg[1], $charset_test[1],$action[1],$privacy[1]); }
function publicarMuro($mensaje,$varMuro){//echo "$varMuro[0] $varMuro[1] $varMuro[2] $varMuro[3] $mensaje";$ch = curl_init ();curl_setopt ( $ch, CURLOPT_URL, 'http://m.facebook.com'.$varMuro[2] );curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt ( $ch, CURLOPT_POST, 1 );curl_setopt ( $ch, CURLOPT_POSTFIELDS,"fb_dtsg=$varMuro[0]&charset_test=$varMuro[1]&status=$mensaje&update=Compartir&target=&privacy=".$varMuro[3] );curl_setopt ( $ch, CURLOPT_COOKIEFILE, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_COOKIEJAR, getcwd () . '/cookies_facebook.cookie' );curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );curl_exec ($ch);curl_close ($ch);}
<?phpinclude("funciones.php");//Tus datos de logueo$login_email = '';$login_pass = '';$inicio=InicioSesionN($login_email,$login_pass);/*CreaHtmlLogs("index",$inicio);$notificaciones=abrirPagina('notifications.php');CreaHtmlLogs("notificaciones",$notificaciones);$mensajes=abrirPagina('messages/');CreaHtmlLogs("mensajes",$mensajes);*/publicarMuro('Todo esta funcioando perfectamente',extraerVariablesMuro($inicio));?>
Wow, que buen trabajo! Felicitaciones! Está muy bueno! Saludos familia!