最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Twitter API 1.1 Could not authenticate you 2 - Stack Overflow

programmeradmin0浏览0评论

I'm trying to get result from this query.

.1/search/tweets.json?q=?&geocode=39.893280,32.779655,5km&count=100

I'm getting code:32 Could not authenticate you error. I'm using parse cloud code.

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

I generated everything from here. So the keys and the signature is correct. Probably the urlLink I'm giving is in wrong format but I checked it a few times. What is wrong here?

Here is the curl code which works correct. Newlines are just for better readability.

curl --get '.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

I'm trying to get result from this query.

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

I'm getting code:32 Could not authenticate you error. I'm using parse cloud code.

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

I generated everything from here. So the keys and the signature is correct. Probably the urlLink I'm giving is in wrong format but I checked it a few times. What is wrong here?

Here is the curl code which works correct. Newlines are just for better readability.

curl --get 'https://api.twitter./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
Share Improve this question edited Mar 31, 2015 at 15:39 Thellimist asked Mar 30, 2015 at 21:36 ThellimistThellimist 4,0277 gold badges34 silver badges51 bronze badges 7
  • What's with q=?? Shouldn't that be your search term? – Phil Commented Mar 31, 2015 at 0:39
  • search everything in the specified location. like SELECT * – Thellimist Commented Mar 31, 2015 at 8:34
  • Then it should be url encoded like it is in your curl request – Phil Commented Mar 31, 2015 at 20:09
  • I tried that but maybe I did something wrong can you provide an example? – Thellimist Commented Mar 31, 2015 at 20:17
  • 1 It's more apt to close as a "typo". FYI, you should pay close attention to the documentation - "q: A UTF-8, URL-encoded search query of 500 characters maximum, including operators" – Phil Commented Mar 31, 2015 at 23:38
 |  Show 2 more ments

1 Answer 1

Reset to default 6

The problem was instead of ? I should have wrote %3F

Here is the lastest version of the query

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

Doc: https://dev.twitter./rest/reference/get/search/tweets

q: A UTF-8, URL-encoded search query of 500 characters maximum, including operators

发布评论

评论列表(0)

  1. 暂无评论