I started learning the Twitter API. I want to make a simple search for a keyword e.g ‘bananaz’ and get some info from the JSON data it will return.
I use PHP and abrahams twitteroauth library.
My code goes something like this:
require_once('/twitteroauth.php');
$connection = new TwitterOAuth ('****', '****', '****', '******');
$statuses = $connection->get('search/tweets.json?q=bananaz');
print_r($statuses);
But all it returns is “Sorry, that page does not exist [code] => 34”
Updated Answer Oct 2013
TwitterOAuth now supports the new Twitter API 1.1 and searches are authenticated (documentation) – a search query will work similar to the original code:
Old answer (Twitter API v1)
Twitter doesn’t require authentication for searches, so TwitterOAuth doesn’t support it. The URL for search is different to the API URL which is why you are getting the “page does not exist error” (Twitter doco).
To get around this you may be able to use the full URL when doing a call through TwitterOAuth:
However the author of the library recommends just using cURL for searches, saving on the overhead of using the library: