How to get access token from Instagram token using jQuery or php

被刻印的时光 ゝ 提交于 2019-12-06 08:39:32

问题


I am new to the Instagram API and am finding some issues tying to understand how to get an access token.

What i have done is registered with instagram, created an application, and used the the client id and redirect url which when I post the following into a browser gives me a code=token

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

response

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

From this how do i get an access token?

<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>

回答1:


The flow is well documented at http://instagram.com/developer/authentication/. You're done with step two, now it's on to step three, where you exchange the temporary code for a long lived access token.

The URL for this exchange is https://api.instagram.com/oauth/access_token and you'll need to POST client_id, client_secret, grant_type, redirect_uri, and code per the docs. cURL is the best way to do this.




回答2:


Here's a simple web interface I built for obtaining an Instagram API access token.

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



来源:https://stackoverflow.com/questions/12677551/how-to-get-access-token-from-instagram-token-using-jquery-or-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!