Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API 1.1 Could not authenticate you 2

I'm trying to get result from this query.

https://api.twitter.com/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.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
like image 488
Thellimist Avatar asked Mar 30 '15 21:03

Thellimist


People also ask

Can I use Twitter API without authentication?

You can do application-only authentication using your apps consumer API keys, or by using a App only Access Token (Bearer Token). This means that the only requests you can make to a Twitter API must not require an authenticated user.

How do I authenticate my Twitter App?

Tap the checkbox next to Authentication app. Read the overview instructions, then tap Start. If prompted, enter your password and tap Verify. If you haven't already, we'll ask you to confirm an email for your Twitter account: Enter your email address, then tap Next.

How do I get high access Twitter API?

All Twitter API access requires a developers account, which can be created quickly by signing up. Essential access will be available immediately, and Elevated access can be requested.


1 Answers

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

Here is the lastest version of the query

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

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

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

like image 82
Thellimist Avatar answered Oct 22 '22 15:10

Thellimist