当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Instagram Ajax cURL Login - Page Continuous Refreshing And No Post Data -

问题描述:

Log me when I'm having problems with Instagram cURL.

Constantly refreshing the page or I'm getting the error

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.

<?php

$c = curl_init();

curl_setopt($c, CURLOPT_URL, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_REFERER, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($c, CURLOPT_FAILONERROR, true);

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 10);

curl_setopt($c, CURLOPT_TIMEOUT, 50);

curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_COOKIEJAR, dirname(__FILE__).'/am.txt');

curl_setopt($c, CURLOPT_COOKIEFILE, dirname(__FILE__).'/am.txt');

$page = curl_exec($c);

curl_close($c);

preg_match_all('/<input type="hidden" name="csrfmiddlewaretoken" value="([A-z0-9]{32})"\/>/', $page, $token);

$c = curl_init();

curl_setopt($c, CURLOPT_URL, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_REFERER, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_POST, true);

curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($c, CURLOPT_FAILONERROR, true);

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 10);

curl_setopt($c, CURLOPT_TIMEOUT, 50);

curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);

// curl_setopt($c, CURLOPT_POSTFIELDS, "csrfmiddlewaretoken=".$token[1][0]."&username=beyxxhan1110&password=beyhwwan1100");

curl_setopt($c, CURLOPT_COOKIEJAR, dirname(__FILE__).'/am.txt');

curl_setopt($c, CURLOPT_COOKIEFILE, dirname(__FILE__).'/am.txt');

$page = curl_exec($c);

curl_close($c);

echo $page;

?>

This library is constantly renewing itself

<?php

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$c = curl_init();

curl_setopt($c, CURLOPT_URL, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_REFERER, 'https://instagram.com/accounts/login/?force_classic_login');

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);

curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($c, CURLOPT_COOKIESESSION, FALSE);

$page = curl_exec($c);

curl_close($c);

preg_match_all('/<input type="hidden" name="csrfmiddlewaretoken" value="([A-z0-9]{32})"\/>/', $page, $token);

function Veri($url, $post, $post_data, $user_agent, $cookies) {

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://instagram.com/'.$url);

curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_COOKIESESSION, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

if($post) {

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

}

if($cookies) {

curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');

} else {

curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');

}

$response = curl_exec($ch);

$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

return array($http, $response);

}

$data = "csrfmiddlewaretoken=".$token[1][0]."&password=beyhan1100&username=beyhan1110";;

$agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36";

$login = Veri('/accounts/login/?force_classic_login/', true, $data, $agent, false);

print_r($login);

?>

executing the subject of

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

I get this error.

分享给朋友:
您可能感兴趣的文章:
随机阅读: