Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > HTTP/1.1 301 Moved Permanently Location: https://www.instagram.com/
- > Content-Type: text/plain Server: proxygen Date: Mon, 16 Jan 2017
- > 12:53:26 GMT Connection: keep-alive Content-Length: 0
- >
- > HTTP/1.1 200 OK Content-Type: text/html Vary: Cookie, Accept-Language,
- > Accept-Encoding Content-Language: en Pragma: no-cache Expires: Sat, 01
- > Jan 2000 00:00:00 GMT Strict-Transport-Security: max-age=86400 Date:
- > Mon, 16 Jan 2017 12:53:27 GMT X-Frame-Options: SAMEORIGIN
- > Content-Encoding: gzip Cache-Control: private, no-cache, no-store,
- > must-revalidate Set-Cookie: sessionid=; expires=Thu, 01-Jan-1970
- > 00:00:00 GMT; Max-Age=0; Path=/; HttpOnly; Domain=instagram.com
- > Set-Cookie: csrftoken=uWHWfgmVVhdROoG3HsyIevXMq4mcEGVU; expires=Mon,
- > 15-Jan-2018 12:53:27 GMT; Max-Age=31449600; Path=/; Secure Connection:
- > keep-alive Content-Length: 3373
- <?php
- include_once('simple_html_dom.php');
- $usuario = "pablodalmazzo";
- $password = "kakaroto93";
- $url = 'https://www.instagram.com/';
- $url_login = 'https://www.instagram.com/accounts/login/ajax/';
- $user_agent = array("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 ",
- "(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
- $ch = curl_init();
- $headers = [
- 'Accept-Encoding: gzip, deflate',
- 'Accept-Language: en-US;q=0.6,en;q=0.4',
- 'Connection: keep-alive',
- 'Content-Length: 0',
- 'Host: www.instagram.com',
- 'Origin: https://www.instagram.com',
- 'Referer: https://www.instagram.com/',
- 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
- 'X-Instagram-AJAX: 1',
- 'X-Requested-With: XMLHttpRequest'
- ];
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie/pruebalogininsta3.txt");
- curl_setopt($ch, CURLOPT_REFERER, $sTarget);
- curl_setopt($ch, CURLOPT_HEADER, TRUE);
- $html = curl_exec($ch);
- preg_match_all('/^Set-Cookie:s*([^;]*)/mi', $html, $matches);
- $cookies = array();
- foreach($matches[1] as $item) {
- parse_str($item, $cookie);
- $cookies = array_merge($cookies, $cookie);
- }
- $headers = [
- 'Accept-Language: en-US;q=0.6,en;q=0.4',
- 'Connection: keep-alive',
- 'Content-Length: 0',
- 'Host: www.instagram.com',
- 'Origin: https://www.instagram.com',
- 'Referer: https://www.instagram.com/',
- 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36',
- 'X-Instagram-AJAX: 1',
- 'X-Requested-With: XMLHttpRequest'
- ];
- $cadena_agregar_vector = 'X-CSRFToken:'. $cookies["csrftoken"];
- $headers[] = $cadena_agregar_vector ;
- $sPost=http_build_query(array('username'=>$usuario,'password'=>$password));
- # Creo que falta agregar la variable POST para que mande un POST y no un GET
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_URL, $url_login);
- $html2 = curl_exec($ch);
- curl_setopt($ch, CURLOPT_URL, "http://www.instagram.com/");
- $html4 = curl_exec($ch);
- echo $html4;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement