【问题标题】:trying to access search from browser试图从浏览器访问搜索
【发布时间】:2012-08-01 01:21:45
【问题描述】:

我正在尝试使用 dev.twitter.com 上的应用页面上显示的 oauth_token 和 oauth_token_secret 搜索用户,但我得到了

“无法验证您的身份。”

我使用正确值访问的网址:

https://api.twitter.com/1/users/search.json?q=foo&oauth_token=123&oauth_token_secret=abc

【问题讨论】:

    标签: twitter


    【解决方案1】:

    这里你正在做一个经过身份验证的请求,这是错误的身份验证方式。

    要做你想做的事,你可以做这样的事情(这里计算有多少人在搜索中使用你的应用程序):

    unsigned int nbTweets = 0;
    
    Timeline tl = twitter.search("foo");    // http://search.twitter.com/search.json?q=foo
    
    foreach (Tweet t in tl) {
        // Retrieving the application used to write the tweet in the "source" field of the tweet
        String tweetHTMLSource = t.source; // tweetHTMLSource == '<a href="clientName.callbackURL" rel="nofollow">clientName</a>'
    
        String clientName = tweetHTMLSource.plainText; // clientName == "clientName"
    
        if (clientName == "MYAPPLICATION_NAME") {
            nbTweets++;
        }
    }
    

    【讨论】:

    • 这是不同的,因为您使用的是不需要身份验证的一般搜索,而我使用的是需要身份验证的用户搜索
    • Twitter API 中没有任何端点可用于检索哪些应用程序已获得给定用户的授权。因此,在您的情况下,请照常执行请求(使用经典的 Twitter 请求身份验证)。获得用户后,您可以通过分析每条推文的来源来搜索他们是否使用您的应用程序的时间线,就像在我的小算法中一样。
    猜你喜欢
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 2013-11-06
    • 2011-11-15
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多