Advertisement
Guest User

Untitled

a guest
Nov 18th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement