Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2.  
  3. $cookie = [];
  4.  
  5. $index_url = 'https://twitter.com';
  6.  
  7. $token = curl_init();
  8. curl_setopt_array($token, [
  9. CURLOPT_URL => $index_url,
  10. CURLOPT_CUSTOMREQUEST => 'GET',
  11. CURLOPT_RETURNTRANSFER => true,
  12. CURLOPT_SSL_VERIFYPEER => false,
  13. CURLOPT_SSL_VERIFYHOST => false,
  14. CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
  15. CURLOPT_REFERER => $index_url,
  16. CURLOPT_HEADER => TRUE,
  17. CURLOPT_HEADERFUNCTION => function($curl, $header) use (&$cookie){
  18. if(stripos($header, 'Set-Cookie:') === 0){
  19. if(preg_match('/Set-Cookie:s?(.*?);/i', $header, $matches)) {
  20. // $cookie .= $matches[1] . '; ';
  21. $cookie[] = $matches[1];
  22. }
  23. }
  24. //var_dump($header);
  25. return strlen($header);
  26. }
  27. ]
  28. );
  29. $access = curl_exec($token);
  30.  
  31. preg_match('/value="(.*?)" name="authenticity_token"/', $access, $matches);
  32.  
  33. $authenticity_token = $matches[1];
  34.  
  35. //how to use cookie array
  36. //$cookie[0];
  37.  
  38. $username = 'jhonesstevan';
  39. $password = 'laranjao1020';
  40.  
  41. $session_post = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&authenticity_token=$authenticity_token";
  42.  
  43. $session_url = 'https://twitter.com/sessions';
  44.  
  45. curl_setopt_array($token, [
  46. CURLOPT_URL => $session_url,
  47. CURLOPT_CUSTOMREQUEST => 'POST',
  48. CURLOPT_POSTFIELDS => $session_post,
  49. CURLOPT_RETURNTRANSFER => true,
  50. CURLOPT_HTTPHEADER => [
  51. "Content-type: application/x-www-form-urlencoded"
  52. ],
  53. CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
  54. CURLOPT_HEADER => TRUE,
  55. CURLOPT_FOLLOWLOCATION => 1,
  56. ]
  57.  
  58. );
  59. $auth = curl_exec($token);
  60.  
  61. var_dump($auth);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement