Api.twitter.com/1.1/search/tweets.json


#1

Hi, I don’t know if any one has come across this issue.
I am a researcher doing work in healthcare at a UK University.
We have been working with atom and json outputs using http://search.twitter.com/search.format.
As with the recent announcements of API V1.1, we wrote some PHP CURL code to do the twitter search for us using OAuth and https://api.twitter.com/1.1/search/tweets.json.
On running the php code, we are getting the error “Could not authenticate you”.
Whilst we ran other calls e.g https://api.twitter.com/1.1/statuses/home_timeline.json all seem to be working fine.
Would some one tell me if I am missing something here?
Can I continue to use the http://search.twitter.com/search.format endpoint?
Many thanks is advance.


#2

I am having same issue?


#3

Perhaps there’s an encoding error in your query string for the search context? Can you share your signature base string or query string for a little debugging?


#4

This is my query string:

https://api.twitter.com/1.1/search/tweets.json?q=@FreshPictures&result_type=recent&count=100&include_entities=true

My Authorization header is generated at 11:28 PM 10/9/2012 GMT:

Authorization: OAuth realm=“Twitter API”,oauth_consumer_key=“TgC0JrUEKNdnfeDlpp1Ww”,oauth_nonce=“4D048AEC”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1349738903”,oauth_token=“321368584-2gAtKcrWZwejAyZIGjUq2Y9V1lo67HgnqbAlLyKw”,oauth_version=“1.0”,oauth_signature=“LP8W3WvHQt8Vda4GddBQ%2BYGASTQ%3D”


#5

In this case, check the encoding on that @ symbol, which isn’t a valid character for this part of a URL – you want to use “%40” instead…


#6

it did not work for “%40” … however, when i removed the “%40” completely the request went fine.

Is there something else that I need to encode beside the “@”


#7

I would look deeper into your OAuth code and see specifically what it’s trying to do with the signature base string and the usage of these characters.


#8

Thanks for your quick response…

I have 2 cases:

Case 1: Not Working

POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fsearch%2Ftweets.json%3Fq%3D%2540FRESHPICTURES%26result_type%3Drecent%26count%3D100%26since_id%3D0%26include_entities%3Dtrue&oauth_consumer_key%3DTgC0JrUEKNdnfeDlpp1Ww%26oauth_nonce%3DNjM0ODU2MTIyODEyODMwNDE2%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1350004681%26oauth_token%3D321368584-2gAtKcrWZwejAyZIGjUq2Y9V1lo67HgnqbAlLyKw%26oauth_version%3D1.0

================

Case 2: Working

POST&http%3A%2F%2Fsearch.twitter.com%2Fsearch.json%3Fq%3D%2540FRESHPICTURES%26result_type%3Drecent%26rpp%3D100%26since_id%3D0%26include_entities%3Dtrue&oauth_consumer_key%3DTgC0JrUEKNdnfeDlpp1Ww%26oauth_nonce%3DNjM0ODU2MTI0NzYwOTQxODQy%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1350004876%26oauth_token%3D321368584-2gAtKcrWZwejAyZIGjUq2Y9V1lo67HgnqbAlLyKw%26oauth_version%3D1.0

Thank you,


#9

Case 1: It looks like you’re trying to issue a HTTP POST to this method – it’s a GET-based method. I also don’t recommend using since_id=0 but instead use an actual value or omit it entirely. You may also just be having conflicting HTTP methods (you’re performing a GET perhaps but your OAuth says its a POST)

Case 2: Your OAuth in this case is just being completely ignored as the search.twitter.com server doesn’t support OAuth.


#10

I had the same problem.

I changed the “oAuth::getOAuthHeader” function.

  • buildOAuthRawDataKeyValPairs( dataPart, true, rawKeyValuePairs );
  • buildOAuthRawDataKeyValPairs( dataPart, false, rawKeyValuePairs );

Now I don’t have any problems.


#11

could anyone guide me about the coding in php how to use twitter search api.


#12

There is a worst api documentation then Twitter API?