Twitter Search API v1.1,仅限应用程序身份验证

I have prepared my bearer token for app only auth as per the documentation and I have my header now, but I don't know how to send it to get a response:

      <?php
                $headers = array( 
                    "GET /1.1/search/tweets.json? HTTP/1.1", 
                    "Host: api.twitter.com", 
                    "User-Agent: my Twitter App v.1",

                    "Authorization: Bearer mybearertoken",


                ); 
$url = "https://api.twitter.com/1.1/search/tweets.json?q=%23SOMEHASHTAG&count=100";

Normally, with the v1, I would just do a $result=json_decode(file_get_contents($url), true) but I don't know how to proceed in this case.

You can play with the PHP's context parameters. More information can be found here: http://docs.php.net/context

And in your case the code would be something like the following:

$headers = array( 
            "GET /1.1/search/tweets.json? HTTP/1.1", 
             "Host: api.twitter.com", 
             "User-Agent: my Twitter App v.1",
             "Authorization: Bearer mybearertoken",
             ); 
$url = "https://api.twitter.com/1.1/search/tweets.json?q=%23SOMEHASHTAG&count=100";

$context = stream_context_create($headers);

$result=json_decode(file_get_contents($url, false, $context));