【问题标题】:Twitter API 1.1 Could not authenticate you 2Twitter API 1.1 无法对您进行身份验证 2
【发布时间】:2023-03-15 07:23:01
【问题描述】:

我正在尝试从此查询中获取结果。

https://api.twitter.com/1.1/search/tweets.json?q=?&geocode=39.893280,32.779655,5km&count=100

我收到code:32 Could not authenticate you 错误。我正在使用解析云代码。

Parse.Cloud.httpRequest({
    method: 'GET',
    url: urlLink,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization" : 'OAuth oauth_consumer_key="hKHVs8mDhW1rvZaPSLV9NywDS", oauth_nonce="5930fc59da48a2b30a5ff90939184b82", oauth_signature=somethingcorrect, oauth_signature_method="HMAC-SHA1", oauth_timestamp="1427745599", oauth_token="2900478017-RUQFnvSL7Vh1WohOBLbkswx55vtcgbnaexNt6ed", oauth_version="1.0"'
    },
    body: {
    },
    success: function(httpResponse) {
        // console.log(httpResponse.text);
        response.success(httpResponse.text);
    },
    error: function(httpResponse) {
        response.error('Request failed with response ' + httpResponse.status + ' , ' + JSON.stringify(httpResponse));
    }
});

我从here 生成了所有内容。所以密钥和签名是正确的。可能我提供的 urlLink 格式错误,但我检查了几次。这里有什么问题?

这是正确运行的 curl 代码。换行只是为了提高可读性。

curl --get 'https://api.twitter.com/1.1/search/tweets.json' 
--data 'count=100&geocode=39.893280%2C32.779655%2C5km&q=%3F' 
--header 'Authorization: OAuth oauth_consumer_key="hKHVs8mDhW1rvZaPSLV9NywDS", oauth_nonce="5930fc59da48a2b30a5ff90939184b82", oauth_signature=somethingcorrect, oauth_signature_method="HMAC-SHA1", oauth_timestamp="1427745599", oauth_token="2900478017-RUQFnvSL7Vh1WohOBLbkswx55vtcgbnaexNt6ed", oauth_version="1.0"' --verbose

【问题讨论】:

  • q=? 是怎么回事?那不应该是你的搜索词吗?
  • 搜索指定位置的所有内容。像 SELECT *
  • 那么它应该像在你的 curl 请求中一样进行 url 编码
  • 我试过了,但也许我做错了什么你能举个例子吗?
  • 它更容易以 "typo" 的形式关闭。仅供参考,您应该密切注意documentation - "q:UTF-8,URL-encoded 搜索查询,最多 500 个字符,包括运算符"

标签: javascript twitter parse-platform twitter-oauth


【解决方案1】:

问题是我应该写%3F而不是?

这是查询的最新版本

https://api.twitter.com/1.1/search/tweets.json?q=%3F&geocode=39.893280,32.779655,5km&count=100

文档:https://dev.twitter.com/rest/reference/get/search/tweets

q:一个 UTF-8、URL 编码的搜索查询,最多 500 个字符,包括运算符

【讨论】:

    猜你喜欢
    • 2013-11-28
    • 2021-04-14
    • 2022-01-01
    • 2017-07-11
    • 2011-08-04
    • 2013-02-15
    • 1970-01-01
    • 2017-12-30
    • 2013-01-20
    相关资源
    最近更新 更多