Can you give me a php script who return the firts 3 trending topic of twitter? thanks
+2
A:
I'm not sure you should be asking people to write code for you, but anyway, here you are.
<?php
$request = file_get_contents( 'http://search.twitter.com/trends/current.json' );
$json = json_decode( $request, true );
$trends = $json[ 'trends' ];
$keys = array_keys( $trends );
$trends = $trends[ $keys[ 0 ] ];
$trends = array(
$trends[ 0 ][ 'name' ],
$trends[ 1 ][ 'name' ],
$trends[ 2 ][ 'name' ]
);
Simon
2010-06-11 03:32:59
If you want an associative array out of `json_decode`, you can make the second paramater `true` instead of getting the object and then casting it.
Charles
2010-06-11 04:21:38
+1. Forgot about that parameter :)
Simon
2010-06-11 04:34:06