Callum Whyte
Callum Whyte

Reputation: 2429

Twitter Search API no results

I have a PHP script that uses the Twitter Search API to find tweets matching a search but for some reason is no longer working and is not returning any results.

Does anyone know what is going wrong?

<?php   

$search=json_decode(file_get_contents('https://search.twitter.com/search.json?q='.urlencode($_GET[q]).'%20vine.co%2Fv%2F&result_type=recent&include_entities=1&rpp=9&page='.$_GET[page]));
foreach($search->results as $result){
 foreach($result->entities->urls as $url){
   echo $url->expanded_url;
 }
}

?>

Upvotes: 0

Views: 1094

Answers (1)

Jimbo
Jimbo

Reputation: 26624

A Bug

There's currently a bug in the 1.0 API - see this bug report. Anyway, unauthenticated requests will stop working in four days.

Deprecated (and retired) 1.0 API

Twitter requires you to use authenticated requests (OAuth) because, five days from now, the v1.0 API will be removed completely.

What this means for you is that a simple:

file_get_contents( . . . )

... well, for the 1.0 api, it'll just stop returning data! Five days from now, you won't be able to use that any more!

See this post I posted today for a little background information and proof of the API removal date (five days from now).

See this post for a walk through of how to make authenticated requests using Twitter's 1.1 API. It's pretty simple if you use this library and only a few lines of code to make the actual request.

Upvotes: 1

Related Questions