Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <?php
  2.  
  3. $username = 'pdosilva1020';
  4. $password = 'laranjao102020';
  5.  
  6. function start($username, $password) {
  7. $request = curl_init();
  8. curl_setopt_array($request, [
  9. CURLOPT_URL => 'https://twitter.com',
  10. CURLOPT_CUSTOMREQUEST => 'GET',
  11. CURLOPT_RETURNTRANSFER => true,
  12. CURLOPT_SSL_VERIFYPEER => false,
  13. CURLOPT_SSL_VERIFYHOST => false,
  14. CURLOPT_HEADER => true,
  15. CURLOPT_COOKIEJAR => getcwd() . '/cookies/' . $username . '.txt',
  16. CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
  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. }
  22. }
  23. return strlen($header);
  24. }
  25. ]
  26. );
  27. $response = curl_exec($request);
  28.  
  29. preg_match('/value="(.*?)" name="authenticity_token"/', $response, $matches);
  30.  
  31. $authenticity_token = $matches[1];
  32.  
  33. $post_fields = http_build_query([
  34. 'session' => [
  35. 'username_or_email' => $username,
  36. 'password' => $password
  37. ],
  38. 'return_to_ssl' => true,
  39. 'scribe_log' => '',
  40. 'redirect_after_login' => '/',
  41. 'authenticity_token' => $authenticity_token
  42. ]
  43. );
  44.  
  45. curl_setopt_array($request, [
  46. CURLOPT_URL => 'https://twitter.com/sessions',
  47. CURLOPT_CUSTOMREQUEST => 'POST',
  48. CURLOPT_POSTFIELDS => $post_fields,
  49. CURLOPT_RETURNTRANSFER => true,
  50. CURLOPT_SSL_VERIFYPEER => false,
  51. CURLOPT_SSL_VERIFYHOST => false,
  52. CURLOPT_HEADER => true,
  53. CURLOPT_FOLLOWLOCATION => true,
  54. CURLOPT_COOKIE => $cookie,
  55. CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
  56. CURLOPT_HTTPHEADER => [
  57. 'accept-language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4',
  58. 'content-type: application/x-www-form-urlencoded',
  59. 'origin: https://twitter.com',
  60. 'referer: https://twitter.com/login',
  61. ],
  62. ]
  63. );
  64.  
  65. $response = curl_exec($request);
  66. curl_close($request);
  67.  
  68. }
  69.  
  70. var_dump(start($username, $password));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement