我正在尝试编写代码来返回过去 100 条推文,其中包含推特上当前的热门话题标签。首先,我获取当前趋势的内容并仅隔离趋势主题标签:
$json_output=json_decode(file_get_contents("https://api.twitter.com/1/trends/23424977.json"),true);
print_r($json_output);
foreach($json_output[0]['trends'] as $trend) {
if ($trend['name'][0] === '#') {
echo $trend['name'];
$hashtag == $trend['name'];
}
}
但与其呼应趋势['name'],我想使用它来使用 twitter 搜索方法进行搜索。通过在 if 语句中添加类似这样的内容:
$past_uses = json_decode(file_get_contents("http://search.twitter.com/search.json?q="$hashtag"&rpp=100&include_entities=true&result_type=popular"),true);
但是变量 $hashtag 没有正确定义,我不知道为什么。(当我尝试回显 $hashtags 以检查它是否存储了正确的值时,它不会打印任何内容。)那么,我应该更改什么以便可以在 URL 中使用 $trend['name'] 的值搜索方法以获取包含趋势标签的过去推文?
谢谢!