2010-06-11 25 views

回答

4

我不確定你應該問人們爲你寫代碼,但無論如何,你在這裏。

<?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' ] 

); 

注意:上面使用Twitter的API不再有效

+2

如果你想要一個關聯數組出來'json_decode',可以使第二paramater TRUE;而不是獲取該對象,然後鑄造它。 – Charles 2010-06-11 04:21:38

+0

+1。忘了那個參數:) – Simon 2010-06-11 04:34:06

相關問題