@Deterrent

Авторизация в instagram через curl, что дальше?

Пытаюсь сделать так.

<?php
ini_set('display_errors', TRUE); error_reporting(E_ALL);

$login_url = 'https://www.instagram.com/';
$login_url_post = 'https://www.instagram.com/accounts/login/ajax/';

$agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0";
$post_data = 'username=user&password=pass';

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $login_url );
//curl_setopt($ch, CURLOPT_POST, 1 );
//curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/home/deterrent/www/site.ru/curl/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/home/deterrent/www/site.ru/curl/cookie.txt');

$postResult = curl_exec($ch);

var_dump ($postResult);

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_USERAGENT, $agent);
curl_setopt($ch2, CURLOPT_URL, $login_url_post );
curl_setopt($ch2, CURLOPT_POST, 1 );
curl_setopt($ch2, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch2, CURLOPT_COOKIEJAR, '/home/deterrent/www/site.ru/curl/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/home/deterrent/www/site.ru/curl/cookie.txt');

$postResult2 = curl_exec($ch2);

var_dump ($postResult2);
?>


Но получаю страничку инстаграма с надписью
"This page could not be loaded. If you have cookies disabled in your browser, or you are browsing in Private Mode, please try enabling cookies or turning off Private Mode, and then retrying your action."

Куки у меня пишутся в файл. Если браузером смотреть. то на https://www.instagram.com/accounts/login/ajax/ передается юзернейм и пассворд, ну и куки полученные вроде как тоже отправляться должны. Подскажите что я упустил, где может быть ошибка.
  • Вопрос задан
  • 857 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы