0
我想使用API登錄instagram。但我得到的錯誤:php instagram api登錄錯誤
{"status":"fail","message":"Your version of Instagram is out of date. Please upgrade your app to log in to Instagram."}
而且我的PHP代碼:
function open($url,$post="") {
$cookies = 'cookies.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
if ($post != "") {
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_USERAGENT, 'Instagram');
curl_setopt($ch,CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_REFERER, "");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function _render_form($data) {
$t = "";
foreach ($data as $k=>$v) { $t .= "&$k=$v";}
return str_replace("###&","","###".$t);
}
function login($username, $password) {
$post = _render_form(array("username" => $username, "password" => $password, "device_id" => "MY_DEVICE_ID"));
$isi = open("https://instagram.com/api/v1/accounts/login/", $post);
echo $isi; die;
}
$login = login('MY_USERNAME', 'MY_PASSWORD');
我改變了設備ID到我的手機的設備ID。但問題沒有解決......任何想法?
我的猜測是你正在使用API的過時形式。檢查_current_ API文檔並確保您的代碼符合它。 –