Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. $sTarget = "https://twitter.com";
  2.  
  3. curl_setopt($ch, CURLOPT_URL, $sTarget);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  7. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  8. curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie". $usuario ."_tweet.txt");
  9. curl_setopt($ch, CURLOPT_COOKIEJAR, $usuario ."_tweet.txt");
  10. curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  11. curl_setopt($ch, CURLOPT_REFERER, $sTarget);
  12. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  13.  
  14. $html = curl_exec($ch);
  15.  
  16. if(curl_errno($ch))
  17. {
  18. echo 'error:' . curl_error($c);
  19. }
  20.  
  21. preg_match('<input name="authenticity_token" type="hidden" value="([a-zA-Z0-9]*)">', $html, $match);
  22.  
  23. $authenticity_token = $match[1];
  24.  
  25. if ($authenticity_token == "");
  26. {
  27. preg_match('<input type="hidden" value="([a-zA-Z0-9]*)" name="authenticity_token">', $html, $matchprima);
  28. $authenticity_token = $matchprima[1];
  29. }
  30.  
  31.  
  32. $username = $usuario;
  33. $password = "*******";
  34.  
  35. $sPost = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&authenticity_token=$authenticity_token";
  36.  
  37. $sTarget = "https://twitter.com/sessions";
  38.  
  39. curl_setopt($ch, CURLOPT_URL, $sTarget);
  40. curl_setopt($ch, CURLOPT_POST, true);
  41. curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  42. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  43. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
  44. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  45. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  46. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  47. # display server response
  48. $htmldos = curl_exec($ch);
  49.  
  50. preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $htmldos, $matches);
  51. $cookies = array();
  52. foreach($matches[1] as $item) {
  53. parse_str($item, $cookie);
  54. $cookies = array_merge($cookies, $cookie);
  55. }
  56. var_dump($cookies);
  57.  
  58.  
  59. if(curl_errno($ch))
  60. {
  61. echo 'error:' . curl_error($ch);
  62. }
  63.  
  64. <?php
  65.  
  66. include_once('simple_html_dom.php');
  67.  
  68. global $usuario;
  69. $usuario = "universohumor2"; //your twitter account username
  70.  
  71. $ch = curl_init();
  72.  
  73. /************************************** COMIENZAN LAS LLAMADAS A FUNCIONES *************************************/
  74. /***************************************************************************************************************/
  75.  
  76. $vector_retorno = logueo_twitter($ch);
  77.  
  78.  
  79. /******************************************************************************************************************/
  80.  
  81. function logueo_twitter($ch)
  82. {
  83.  
  84. //$ch = curl_init();
  85.  
  86. global $usuario;
  87.  
  88. $sTarget = "https://twitter.com";
  89.  
  90. curl_setopt($ch, CURLOPT_URL, $sTarget);
  91. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  92. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  93. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  94. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  95. curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie". $usuario ."_tweet.txt");
  96. curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  97. curl_setopt($ch, CURLOPT_REFERER, $sTarget);
  98. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  99.  
  100. $html = curl_exec($ch);
  101.  
  102. if(curl_errno($ch))
  103. {
  104. echo 'error:' . curl_error($c);
  105. }
  106.  
  107. preg_match('<input name="authenticity_token" type="hidden" value="([a-zA-Z0-9]*)">', $html, $match);
  108.  
  109. $authenticity_token = $match[1];
  110.  
  111. if ($authenticity_token == "");
  112. {
  113. preg_match('<input type="hidden" value="([a-zA-Z0-9]*)" name="authenticity_token">', $html, $matchprima);
  114. $authenticity_token = $matchprima[1];
  115. }
  116.  
  117.  
  118. $username = $usuario;
  119. $password = "password"; // your twitter account password
  120.  
  121. $sPost = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&authenticity_token=$authenticity_token";
  122.  
  123. $sTarget = "https://twitter.com/sessions";
  124.  
  125. curl_setopt($ch, CURLOPT_URL, $sTarget);
  126. curl_setopt($ch, CURLOPT_POST, true);
  127. curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  128. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  129. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
  130. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  131. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  132. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  133. # display server response
  134. $htmldos = curl_exec($ch);
  135.  
  136. //echo $htmldos;
  137.  
  138. if(curl_errno($ch))
  139. {
  140. echo 'error:' . curl_error($ch);
  141. }
  142.  
  143. $vector["sPost"] = $sPost;
  144. $vector["authenticity_token"] = $authenticity_token;
  145.  
  146. return $vector;
  147.  
  148. }
  149.  
  150. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement