I am currently calling Twitter's "Trending" API with PHP and I want to return the top 10 trending topics. Currently it appears to be echoed into an array but I can't work out how to get an individual piece of data on it's one.
I want to just return the name
attribute for each one. How can I do this?
My existing code is:
<?
$search=file_get_contents("https://api.twitter.com/1/trends/1.json");
print_r(json_decode($search));
?>
Decoded array:
Array
(
[0] => stdClass Object
(
[trends] => Array
(
[0] => stdClass Object
(
[name] => #EuroclubSoloEnEuropaFM
[url] => http://twitter.com/search?q=%23EuroclubSoloEnEuropaFM
[promoted_content] =>
[query] => %23EuroclubSoloEnEuropaFM
[events] =>
)
[1] => stdClass Object
(
[name] => #NBABands
[url] => http://twitter.com/search?q=%23NBABands
[promoted_content] =>
[query] => %23NBABands
[events] =>
)
//...