Devrim
Devrim

Reputation: 2914

twitter search api not returning results

i'm doing api calls from php backend like this:

$term     = "AT&T Park";        
$q        = '"'. urlencode($term) .'"';
$url      = "http://search.twitter.com/search.json?q={$q}&rpp=100";
$api_call = file_get_contents($url);

it's not returning anything, but same api call working just fine on my terminal.

here is a little screencast showing what's going on:

http://screencast.com/t/RnZsrwfGcc2q

any ideas?

Upvotes: 2

Views: 608

Answers (2)

Gabriel Sosa
Gabriel Sosa

Reputation: 7956

you need to urlencode the quotes too.

change your code to the following

$term     = '"AT&T Park"';
$q        = urlencode($term);
$url      = "http://search.twitter.com/search.json?q={$q}&rpp=100";
$api_call = file_get_contents($url);

and it should work

Upvotes: 1

gen_Eric
gen_Eric

Reputation: 227310

You can use cURL in your PHP file. This may work.

https://www.php.net/manual/en/function.curl-init.php

Upvotes: 0

Related Questions