Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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_COOKIEJAR, $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))
- {
- echo 'error:' . curl_error($c);
- }
- preg_match('<input name="authenticity_token" type="hidden" value="([a-zA-Z0-9]*)">', $html, $match);
- $authenticity_token = $match[1];
- if ($authenticity_token == "");
- {
- preg_match('<input type="hidden" value="([a-zA-Z0-9]*)" name="authenticity_token">', $html, $matchprima);
- $authenticity_token = $matchprima[1];
- }
- $username = $usuario;
- $password = "*******";
- $sPost = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&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_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
- 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);
- preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $htmldos, $matches);
- $cookies = array();
- foreach($matches[1] as $item) {
- parse_str($item, $cookie);
- $cookies = array_merge($cookies, $cookie);
- }
- var_dump($cookies);
- if(curl_errno($ch))
- {
- echo 'error:' . curl_error($ch);
- }
- <?php
- include_once('simple_html_dom.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))
- {
- echo 'error:' . curl_error($c);
- }
- preg_match('<input name="authenticity_token" type="hidden" value="([a-zA-Z0-9]*)">', $html, $match);
- $authenticity_token = $match[1];
- if ($authenticity_token == "");
- {
- preg_match('<input type="hidden" value="([a-zA-Z0-9]*)" name="authenticity_token">', $html, $matchprima);
- $authenticity_token = $matchprima[1];
- }
- $username = $usuario;
- $password = "password"; // your twitter account password
- $sPost = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&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_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
- 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