簡體   English   中英

如何使用jQuery或php從Instagram令牌獲取訪問令牌

[英]How to get access token from Instagram token using jQuery or php

我是Instagram API的新手,我發現了一些問題,想要了解如何獲取訪問令牌。

我所做的是在instagram注冊,創建了一個應用程序,並使用客戶端ID和重定向URL,當我將以下內容發布到瀏覽器中時,我給出了一個代碼=令牌

https://api.instagram.com/oauth/authorize/?client_id=65c3052cc4494f87bc7f941b61b1f3f5&redirect_uri=http://www.chillwebdesign.co.uk/feedcube/instagram&response_type=code

響應

http://www.chillwebdesigns.co.uk/feedcube/instagram/?code=462318f96370433eac29a5f845aa0829

從這個我如何獲得訪問令牌?

<div class="pics"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">

$.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/users/[UserID]/media/recent/?access_token=[CODE]",
        success: function(data) {

        for (var i = 0; i < 10; i++) {
            $(".pics").append("<a target='_blank' href='" + data.data[i].link + "'><img src='" + data.data[i].images.low_resolution.url +"'></img></a>");
        }
        }

    });
});


</script>

該流程已在http://instagram.com/developer/authentication/中詳細記錄 您已完成第二步,現在它已進入第三步,您可以在其中交換長期訪問令牌的臨時代碼。

此交換的URL為https://api.instagram.com/oauth/access_token ,您需要根據文檔POST POST client_id,client_secret,grant_type,redirect_uri和代碼。 cURL是最好的方法。

這是我為獲取Instagram API訪問令牌而構建的簡單Web界面。

http://jelled.com/instagram/access-token

暫無
暫無

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

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