2014-01-05 86 views
0

我正在进行客户端身份验证。通过InstagramAPI。 一旦我得到了accesstoken,我尝试做一个非常简单的getrequest建立这样的:instagram jquery获取标签名错误

var tag, //insert from input text 
    access_token = "myaccesstoken", 
    url = "https://api.instagram.com/v1/tags/" + tag + "/media/recent?access_token"+myaccesstoken 

$.get(url, {}, function(data) { console.log(data) }); 

的问题是getrequest永远不会奏效。检查网络时,它被标记为红色并且canceled。 如果我在浏览器中输入完整的url,我会得到正确的response。任何想法?

回答

1

继承人什么我使用Instagram的API的对我的作品:

$(document).ready(function() { 


    function docallUserlookup() { 
     var tag='football'; 

      $.ajax({ 
       type : 'GET', 
       url : 'https://api.instagram.com/v1/tags/' + tag + '/media/recent?access_token=ACCESS_TOKEN_GOES_HERE', 
       dataType : 'jsonp', 
       success : function(jsonData) { 


        //to test it out and see a bit of the returned data, 
        //lets show the users full name in the console... 
        console.log('found data for: ' + jsonData.data[0].user.username); 

        //... and append it to body 
        $('#mainDiv').html(jsonData.data[0].user.username); 

       }, 
       error : function() { 
        alert('Problem getting Instagram users data! Try again.'); 
       } 
      }); 
    }; 


docallUserlookup(); 

}); 

通过APIGEE.com的API周围玩帮助了很多,当我凝视着使用它。 (希望它可以在这里提及该网址/网站,并且它没有违反任何条款)。

+0

这个问题恰恰是'dataType'(我昨天晚上发现的,但是Upvote无论如何)都必须设置为'jsonp' – steo