As you know, authenticated requests are now required, so there's a few things that you may need to take a look at first. The new 1.1 search, how to use hashtags, and authentication.
Twitter Search for 1.1
The new twitter search api docs can be found here. According to these docs:
https://api.twitter.com/1.1/search/tweets.json
is the new resource URL to use for search.
Hashtag searches
You've got that part right! %23
decodes to a #
character.
Authentication
OAuth is a lot more complex. It would help if you just used a library that just worked.
Here's a post a lot of people found useful to help you make authenticated requests to the 1.1 API. This includes a one-file include library to make requests like those you require.
Example
This example assumes you're using the above library and set up your keys etc. To make your request:
// Your specific requirements
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$requestMethod = 'GET';
$getfield = '?q=#baseball&result_type=recent';
// Perform the request
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
Yes, that's it. Apart from the little setting up you need to do (as my post explains), for your dev keys, that's everything you need to perform authenticated requests.
Response
The response is returned to you in JSON. From the overview:
API v1.1 will support JSON only. We've been hinting at this for some time now, first dropping XML support on the Streaming API and more recently on the trends API. We've chosen to throw our support behind the JSON format shared across the platform.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…