вопрос
В чем может быть ошибка ?
<?php
$username = "tt";
$useragent = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13";
$cookie=$username.".txt";
$url="https://instagram.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/".$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/".$cookie);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$page = curl_exec($ch);
preg_match_all('|"csrf_token":"(.+)"|isU',$page,$pos);
echo $pos=$pos[1][0];
$post='username=логин&password=пороль&intent=';
$h = array ("Accept-Encoding: gzip,deflate","Accept-Language: ru,en;q=0.8","Connection: keep-alive","Content-Type: application/x-www-form-urlencoded; charset=UTF-8","X-CSRFToken: ".$pos,"X-Instagram-AJAX: 1","X-Requested-With: XMLHttpRequest");
curl_setopt($ch, CURLOPT_URL, "https://instagram.com/accounts/login/ajax/");
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c,CURLOPT_HTTPHEADER, $h);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/".$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/".$cookie);
echo $page = curl_exec($ch);
$url="https://instagram.com/";
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
?>