Guest User

Untitled

a guest
Jan 9th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. include_once('simple_html_dom.php');
  2.  
  3. $usuario = "username";
  4. $password = "password";
  5.  
  6. $url = 'https://www.instagram.com/';
  7. $url_login = 'https://www.instagram.com/accounts/login/ajax/';
  8. $user_agent = array("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 ",
  9. "(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
  10.  
  11. $ch = curl_init();
  12.  
  13. $headers = [
  14. 'Accept-Encoding: gzip, deflate',
  15. 'Accept-Language: en-US;q=0.6,en;q=0.4',
  16. 'Connection: keep-alive',
  17. 'Content-Length: 0',
  18. 'Host: www.instagram.com',
  19. 'Origin: https://www.instagram.com',
  20. 'Referer: https://www.instagram.com/',
  21. 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
  22. 'X-Instagram-AJAX: 1',
  23. 'X-Requested-With: XMLHttpRequest'
  24. ];
  25.  
  26. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  27. curl_setopt($ch, CURLOPT_URL, $url);
  28.  
  29. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  30. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  31. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  32. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  33. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  34. curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie/pruebalogininsta2.txt");
  35. curl_setopt($ch, CURLOPT_REFERER, $sTarget);
  36. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  37.  
  38. $html = curl_exec($ch);
  39.  
  40. preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $html, $matches);
  41. $cookies = array();
  42. foreach($matches[1] as $item) {
  43. parse_str($item, $cookie);
  44. $cookies = array_merge($cookies, $cookie);
  45. }
  46.  
  47.  
  48. $headers = [
  49. 'Accept-Encoding: gzip, deflate',
  50. //'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
  51. 'Accept-Language: en-US;q=0.6,en;q=0.4',
  52. 'Connection: keep-alive',
  53. 'Content-Length: 0',
  54. 'Host: www.instagram.com',
  55. 'Origin: https://www.instagram.com',
  56. 'Referer: https://www.instagram.com/',
  57. 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
  58. 'X-Instagram-AJAX: 1',
  59. 'X-Requested-With: XMLHttpRequest'
  60. ];
  61.  
  62. $cadena_agregar_vector = 'X-CSRFToken:'. $cookies["csrftoken"];
  63.  
  64. $headers[] = $cadena_agregar_vector ;
  65.  
  66. $sPost = "username=".$usuario . "&password=". $password ;
  67.  
  68. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  69. curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  70. curl_setopt($ch, CURLOPT_URL, $url_login);
  71.  
  72. $html2 = curl_exec($ch);
  73.  
  74. curl_setopt($ch, CURLOPT_URL, "http://www.instagram.com/");
  75.  
  76. $html4 = curl_exec($ch);
  77.  
  78. echo $html4;
Add Comment
Please, Sign In to add comment