如何使用jQuery或php从Instagram令牌获取访问令牌 [英] How to get access token from Instagram token using jQuery or php

查看:106
本文介绍了如何使用jQuery或php从Instagram令牌获取访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Instagram API的新手,正在发现一些有关如何获取访问令牌的问题.

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

我所做的工作已在instagram中注册,创建了一个应用程序,并使用了客户端ID和重定向URL,当我将以下内容发布到浏览器中时,它会给我一个code = 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

响应

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>

推荐答案

http://instagram.com/developer/authentication/.完成第二步,现在到第三步,在这里您将临时代码交换为长寿命的访问令牌.

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.

此交流的网址为 https://api.instagram.com/oauth/access_token,然后您需要根据文档发布client_id,client_secret,grant_type,redirect_uri和代码. cURL是执行此操作的最佳方法.

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.

这篇关于如何使用jQuery或php从Instagram令牌获取访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆