Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在没有访问令牌的情况下调用Instagram API_Instagram_Instagram Api - Fatal编程技术网

在没有访问令牌的情况下调用Instagram API

在没有访问令牌的情况下调用Instagram API,instagram,instagram-api,Instagram,Instagram Api,Instagram最近更改了API,因此不再使用客户端id,而是访问令牌 我只想得到一份我拥有的instagram图片列表,并将其放在我的网站上 这是我以前使用jsonp调用的ajax 'https://api.instagram.com/v1/users/“+”instagram.\u id+”/media/recent/?client\u id=“+”instagram.\u clientId 现在如何使用访问\u令牌?我不希望我网站的访问者每次登录instagram都只是为了查看我网站上的

Instagram最近更改了API,因此不再使用客户端id,而是访问令牌

我只想得到一份我拥有的instagram图片列表,并将其放在我的网站上

这是我以前使用
jsonp
调用的
ajax

'https://api.instagram.com/v1/users/“+”instagram.\u id+”/media/recent/?client\u id=“+”instagram.\u clientId


现在如何使用
访问\u令牌
?我不希望我网站的访问者每次登录instagram都只是为了查看我网站上的instagram图片

如果我没有弄错您的问题,您希望使用访问令牌获取您在instagram上使用新API端点发布的最新媒体

所以,解决这个问题的方法很简单。您不需要访问者每次登录Instagram就可以在Instagram上查看您的媒体

使用访问令牌(首选使用服务器端显式方法):

  • 请求访问代码:

    var redirect_uri=“&redirect_uri=”,
    scope=“&scope=basic”,
    响应类型=“响应类型=代码”,
    url=”https://api.instagram.com/oauth/authorize/?client_id=“++重定向\ uri+响应\类型+范围;
    
  • 令牌的交换代码: 从
    http://your-redirect-uri?code=CODE
    并交换此代码以使用服务器端方法(如cURL)获取访问令牌(首选)

    • 使用端点:
      https://api.instagram.com/oauth/access_token
    • 传递以下参数

      • 客户id
      • 客户机密
      • 授予类型为“授权码”
      • 重定向\u uri
      • 代码
不使用访问令牌(使用隐式方法):

  • 请求访问令牌: 使用
    https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect\u uri=redirect-uri&response\u type=token
  • 获取访问令牌: 使用
    http://your-redirect-uri#access_token=ACCESS-令牌

获取已发布的媒体: 将端点用作
https://api.instagram.com/v1/users/self/media/recent/?access_token=
(如果需要,您可以传递可选参数,如count)



在这里,您的访问者不需要登录他们的帐户。获得链接后,将其保存到数据库中,这样您就不必每次都登录


希望有帮助

什么,如果访问令牌过期?@leFake,您必须要求用户重新登录并重复上述过程
var redirect_uri = "&redirect_uri="<REDIRECT-URI>,
    scope = "&scope=basic",
    response_type = "&response_type=code",
    url = "https://api.instagram.com/oauth/authorize/?client_id=" + <CLIENT-ID> + redirect_uri + response_type + scope;