Twitter trends CURL php
How do I extract current top 10 twitter trends using CURL. All the php tutorials I found seem to use the old twitter urls which have since changed..
Here is a new url I'm struggling with, the new date at the top seems to throw it http://search.twitter.com/trends/current.json
Any ideas how to echo the values?
e.g. output is
stdClass Object ( [trends] => stdClass Object ( [2010-07-03 15:00:00] => Array ( [0] => stdClass Object ( [name] => Mick Jagger [query] => Mick Jagger ) [1] => stdClass Object ( [name] => Leonardo DiCaprio [query] => Leonardo DiCaprio ) [2] => stdClass Object ( [name] => Lionel Messi [query] => Lionel Messi ) [3] => stdClass Object ( [name] => Maradona pelado [query] => Maradona pelado ) [4] => stdClass Object ( [name] => Lizzie McGuire Movie [query] => Lizzie McGuire Movie ) [5] => stdClass Object ( [name] => Thomas Muller [query] => Thomas Muller ) [6] => stdClass Object ( [name开发者_StackOverflow社区] => Gol Anulado [query] => Gol Anulado ) [7] => stdClass Object ( [name] => Serena Williams [query] => Serena Williams ) [8] => stdClass Object ( [name] => Felipe Melo [query] => Felipe Melo ) [9] => stdClass Object ( [name] => Last Airbender [query] => Last Airbender ) ) ) [as_of] => 1278168745 )
You can use json_decode
to parse that source. This should work:
$trends = file_get_contents("http://search.twitter.com/trends/current.json");
print_r(json_decode($trends));
精彩评论