你能给我一个php脚本,在twitter上返回前三个热门话题吗?感谢
答案 0 :(得分: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不再有效