繁体   English   中英

Instagram Api OAuthAccessTokenException 400 错误

[英]Instagram Api OAuthAccessTokenException 400 error

我的 Rails 4.0 Web 应用程序有问题。 我正在使用谷歌地图 Api 返回经纬度,然后将该信息传递给 Instagram 的 Api。 但是我收到一个错误:

{"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"The access_token provided is invalid."}}

我已经完成了创建多个 AccessToken 的过程,但仍然没有。

以前有没有人遇到过这个问题,如果有,你是如何解决的?

这是我的代码:

var codeAddressLat;
var codeAddressLng;
var addMarkerLat;
var addMarkerLng;
var locationLat;
var locationLong;
var accessToken;
var mediaEndPoint;

$(document).ready(function(){


var accessToken="USER_ACCESSTOKEN_PLACEHOLDER";
$('.get_photo').click(function(){
    mediaEndPoint = ("https://api.instagram.com/v1/media/search?lat=" +  locationLat + "&lng=" + locationLong + "&access_token=" + accessToken + "?callback=?");

    if (addMarkerLng !== null  &&  addMarkerLat !== null ) {
        locationLong=addMarkerLng;
        locationLat=addMarkerLat;
        console.log("Add Marker " + mediaEndPoint)
    }else if (codeAddressLat !== null && codeAddressLng !== null) {
        locationLat=codeAddressLat;
        locationLong=codeAddressLng;
        console.log("Code Address: "+ mediaEndPoint)
    }else{
        alert("Oops! Something went wrong, please try again!")
    }
    $(".insta-list").empty();

    $.getJSON(mediaEndPoint, function(jsonResult){

        var items = jsonResult["data"];
        var container =[]
        $.each(items, function(){
        var val = this["images"]["standard_resolution"]["url"]
        container.push("<img src=" + val + ">" );

    });
        $("<ul/>",{
            "class": "insta-list",
            html: imageContanier.join( "" )
        }).appendTo(".modal-body");
    })

});
});

我已经解决了这个问题。

原来我收到错误的原因是: {"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"The access_token provided is invalid."}}

是因为我创建的保存 Instagram API 媒体端点的变量存在语法问题。

我添加了“?callback=?” 绕过 XMLHttpRequest 错误( CORS )。 实际上回调语法应该是“&callback=?”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM