Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $usuario;
- $usuario = "universohumor2"; // your twitter account username
- $ch = curl_init ();
- /**
- * ************************************ COMIENZAN LAS LLAMADAS A FUNCIONES ************************************
- */
- /**
- * ************************************************************************************************************
- */
- $vector_retorno = logueo_twitter ( $ch );
- /**
- * ***************************************************************************************************************
- */
- function logueo_twitter($ch) {
- // $ch = curl_init();
- global $usuario;
- $sTarget = "https://twitter.com";
- curl_setopt ( $ch, CURLOPT_URL, $sTarget );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
- curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
- curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );
- curl_setopt ( $ch, CURLOPT_USERAGENT, $_SERVER ['HTTP_USER_AGENT'] );
- curl_setopt ( $ch, CURLOPT_COOKIEFILE, "/tmp/cookie" . $usuario . "_tweet.txt" );
- curl_setopt ( $ch, CURLOPT_COOKIESESSION, true );
- curl_setopt ( $ch, CURLOPT_REFERER, $sTarget );
- curl_setopt ( $ch, CURLOPT_HEADER, TRUE );
- $html = curl_exec ( $ch );
- if (curl_errno ( $ch )) {
- throw new RuntimeException ( 'curl_exec error. errno:' . curl_errno ( $c ) . '. error:' . curl_error ( $ch ) );
- }
- $domd = @DOMDocument::loadHTML ( $html );
- $xpath = new DOMXPath ( $domd );
- $authenticity_token = $xpath->query ( "//input[@name='authenticity_token']" )->item ( 0 )->getAttribute ( "value" );
- $username = $usuario;
- $password = "password"; // your twitter account password
- $sPost = http_build_query ( array (
- 'session' => array (
- 'username_or_email' => $username,
- 'password' => $password
- ),
- 'return_to_ssl' => true,
- 'scribe_log' => '',
- 'redirect_after_login' => '/',
- 'authenticity_token' => $authenticity_token
- ) );
- $sTarget = "https://twitter.com/sessions";
- curl_setopt ( $ch, CURLOPT_URL, $sTarget );
- curl_setopt ( $ch, CURLOPT_POST, true );
- curl_setopt ( $ch, CURLOPT_POSTFIELDS, $sPost );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
- curl_setopt ( $ch, CURLOPT_USERAGENT, $_SERVER ['HTTP_USER_AGENT'] );
- curl_setopt ( $ch, CURLOPT_HEADER, TRUE );
- curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
- // display server response
- $htmldos = curl_exec ( $ch );
- // echo $htmldos;
- if (curl_errno ( $ch )) {
- echo 'error:' . curl_error ( $ch );
- }
- $vector ["sPost"] = $sPost;
- $vector ["authenticity_token"] = $authenticity_token;
- return $vector;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement