【问题标题】:instagram get tag-name error with jqueryinstagram 使用 jquery 获取标签名错误
【发布时间】:2014-01-05 22:10:56
【问题描述】:

我正在执行客户端身份验证。通过InstagramAPI。 一旦我得到accesstoken,我会尝试做一个非常简单的getrequest,像这样构建它:

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) } );

问题是 get request 永远不会工作。检查网络,它被标记为红色和canceled。 如果我在浏览器中写完整的url,我会得到正确的response。有什么想法吗?

【问题讨论】:

    标签: jquery api get instagram


    【解决方案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 时,通过 APIGEE.com 使用该 API 帮助很大。 (希望可以在这里提及该网址/网站并且它不违反任何条款)。

    【讨论】:

    • 问题正是必须设置为 jsonpdataType(我昨天晚上发现,但还是要支持)必须设置为 jsonp
    猜你喜欢
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 1970-01-01
    • 2016-05-17
    • 2014-07-14
    • 1970-01-01
    相关资源
    最近更新 更多