Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. > HTTP/1.1 301 Moved Permanently Location: https://www.instagram.com/
  2. > Content-Type: text/plain Server: proxygen Date: Mon, 16 Jan 2017
  3. > 12:53:26 GMT Connection: keep-alive Content-Length: 0
  4. >
  5. > HTTP/1.1 200 OK Content-Type: text/html Vary: Cookie, Accept-Language,
  6. > Accept-Encoding Content-Language: en Pragma: no-cache Expires: Sat, 01
  7. > Jan 2000 00:00:00 GMT Strict-Transport-Security: max-age=86400 Date:
  8. > Mon, 16 Jan 2017 12:53:27 GMT X-Frame-Options: SAMEORIGIN
  9. > Content-Encoding: gzip Cache-Control: private, no-cache, no-store,
  10. > must-revalidate Set-Cookie: sessionid=; expires=Thu, 01-Jan-1970
  11. > 00:00:00 GMT; Max-Age=0; Path=/; HttpOnly; Domain=instagram.com
  12. > Set-Cookie: csrftoken=uWHWfgmVVhdROoG3HsyIevXMq4mcEGVU; expires=Mon,
  13. > 15-Jan-2018 12:53:27 GMT; Max-Age=31449600; Path=/; Secure Connection:
  14. > keep-alive Content-Length: 3373
  15.  
  16. <?php
  17.  
  18. include_once('simple_html_dom.php');
  19.  
  20. $usuario = "pablodalmazzo";
  21. $password = "kakaroto93";
  22.  
  23. $url = 'https://www.instagram.com/';
  24. $url_login = 'https://www.instagram.com/accounts/login/ajax/';
  25. $user_agent = array("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 ",
  26. "(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
  27.  
  28. $ch = curl_init();
  29.  
  30. $headers = [
  31. 'Accept-Encoding: gzip, deflate',
  32. 'Accept-Language: en-US;q=0.6,en;q=0.4',
  33. 'Connection: keep-alive',
  34. 'Content-Length: 0',
  35. 'Host: www.instagram.com',
  36. 'Origin: https://www.instagram.com',
  37. 'Referer: https://www.instagram.com/',
  38. 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
  39. 'X-Instagram-AJAX: 1',
  40. 'X-Requested-With: XMLHttpRequest'
  41. ];
  42.  
  43. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  44. curl_setopt($ch, CURLOPT_URL, $url);
  45. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  46. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  48. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  49. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  50. curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie/pruebalogininsta3.txt");
  51. curl_setopt($ch, CURLOPT_REFERER, $sTarget);
  52. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  53.  
  54. $html = curl_exec($ch);
  55.  
  56. preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $html, $matches);
  57. $cookies = array();
  58. foreach($matches[1] as $item) {
  59. parse_str($item, $cookie);
  60. $cookies = array_merge($cookies, $cookie);
  61. }
  62.  
  63.  
  64. $headers = [
  65. 'Accept-Language: en-US;q=0.6,en;q=0.4',
  66. 'Connection: keep-alive',
  67. 'Content-Length: 0',
  68. 'Host: www.instagram.com',
  69. 'Origin: https://www.instagram.com',
  70. 'Referer: https://www.instagram.com/',
  71. 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
  72. 'X-Instagram-AJAX: 1',
  73. 'X-Requested-With: XMLHttpRequest'
  74. ];
  75.  
  76. $cadena_agregar_vector = 'X-CSRFToken:'. $cookies["csrftoken"];
  77.  
  78. $headers[] = $cadena_agregar_vector ;
  79.  
  80. $sPost=http_build_query(array('username'=>$usuario,'password'=>$password));
  81.  
  82.  
  83. # Creo que falta agregar la variable POST para que mande un POST y no un GET
  84.  
  85. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  86. curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  87. curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
  88. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  89. curl_setopt($ch, CURLOPT_URL, $url_login);
  90.  
  91. $html2 = curl_exec($ch);
  92.  
  93. curl_setopt($ch, CURLOPT_URL, "http://www.instagram.com/");
  94.  
  95. $html4 = curl_exec($ch);
  96.  
  97. echo $html4;
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement