使用PHP计算具有给定哈希标记的tweet
我试图使用PHP计算给定标签的tweet数量。 这段源代码是StackOverflow上的某个人提供的。 我是否需要添加任何库或更改任何设置以使函数正常工作? 因为当我运行这段代码时,它只会给我一个空白页使用PHP计算具有给定哈希标记的tweet,php,api,twitter,Php,Api,Twitter,我试图使用PHP计算给定标签的tweet数量。 这段源代码是StackOverflow上的某个人提供的。 我是否需要添加任何库或更改任何设置以使函数正常工作? 因为当我运行这段代码时,它只会给我一个空白页 <?php global $total, $hashtag; //$hashtag = '#supportvisitbogor2011'; $hashtag = '#australialovesjustin'; $total = 0; function ge
<?php
global $total, $hashtag;
//$hashtag = '#supportvisitbogor2011';
$hashtag = '#australialovesjustin';
$total = 0;
function getTweets($hash_tag, $page) {
global $total, $hashtag;
$url = 'http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&';
$url .= 'page='.$page;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$json = curl_exec ($ch);
curl_close ($ch);
//echo "<pre>";
//$json_decode = json_decode($json);
//print_r($json_decode->results);
$json_decode = json_decode($json);
$total += count($json_decode->results);
if($json_decode->next_page){
$temp = explode("&",$json_decode->next_page);
$p = explode("=",$temp[0]);
getTweets($hashtag,$p[1]);
}
}
getTweets($hashtag,1);
echo $total;
?>
阅读这些文章
试着
也许你需要雇人。这是一个帮助开发者的社区,您需要在PHP安装中启用
curl
。检查您的phpinfo()