<!DOCTYPE html>
<html lang="en" class="no-js not-logged-in client-root">
function curl_file($url, $cookie = 'coockie', $post = '', $xhr = '') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
if ($post) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($xhr) {
preg_match('|csrftoken(.*)|', file_get_contents('coockie'), $csrf);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-CSRFToken:' . trim($csrf[1]), 'X-Instagram-AJAX:1', 'X-Requested-With:XMLHttpRequest'));
}
$file = curl_exec($ch);
curl_close($ch);
return $file;
}
curl_file('https://instagram.com/accounts/login/ajax/', 'coockie', 'username=login&password=pass', 1);
echo curl_file('https://instagram.com/', 'coockie', 0, 1);