OAuth.使用OAuth获取tweet时出现未定义错误.重定向方法的回调

OAuth.io undefined error when getting tweets with OAuth.callback for the redirect method

本文关键字:OAuth 错误 重定向 方法 回调 未定义 使用 获取 tweet      更新时间:2023-09-26

我正在使用OAuth。IO连接到twitter。最初我使用的是弹出方法,但由于某种原因,客户端机器在IE11中有一个问题(弹出窗口不关闭,页面和弹出窗口之间丢失了上下文)。无论如何,我决定转移到重定向方法。重定向后,我能够正确地获得令牌并成功连接。然而,当我尝试使用

调用twitter REST API时
success.get('/1.1/statuses/user_timeline.json?screen_name=Microsoft_EDU&exclude_replies=true')

,这完全相同的方式,在弹出方法的工作,我得到"错误"没有更多的描述

有问题的OAuth回调代码:

    OAuth.callback(function (error, success) {
    if (error) {
        //handle Error
    }
    success.get('/1.1/statuses/user_timeline.json?screen_name=Microsoft_EDU&exclude_replies=true')
        .fail(function () {
            $('#result').html($("error loading Tweets");
        })
        .done(function (data) {
            $('#result').html(JSON.stringify(data));
        });
});

下面是popup方法调用,它正在完美地工作并获取tweet:

OAuth.popup(oauthProvider, function(error, success) {
            if (error) {
                // Handle Error
            }
            success.get('/1.1/statuses/user_timeline.json?screen_name=Microsoft_EDU&exclude_replies=true')
                .fail(function () {
                    $('#result').html("error loading Tweets");
                })
                .done(function (data) {
                    $('#result').html(JSON.stringify(data));
                });
        });

知道我可能做错了什么或错过了什么吗?

经过多次试验和错误,原来问题是行OAuth.initialize(关键);S