簡體   English   中英

PHP的Instagram的API登錄錯誤

[英]php instagram api login error

我想使用API​​登錄instagram。 但是我得到了錯誤:

{"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。 但是問題沒有解決……有什么想法嗎?

Instagram不再支持使用用戶名和密碼登錄。 相反,您應該使用oAuth來執行要求身份驗證的請求。

使用圖書館像這一次會比手動執行這一容易得多。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM