【发布时间】:2011-02-23 17:47:13
【问题描述】:
我正在尝试使用http://api.twitter.com/1/trends/current.json?exclude=hashtags,但是遇到了一些问题。
所以,我正在尝试使用:
<?php
$init = 'http://api.twitter.com/1/trends/current.json?exclude=hashtags';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$init);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result, true);
foreach ($obj[0]['trends'] as $trend) {
print $trend['query'];
echo "<br>";
print $trend['name'];
echo "<hr>";
}
?>
我收到了这个错误:
注意:未定义的偏移量:第 11 行 \index.php 中的 0
警告:在第 11 行为 foreach() \index.php 提供的参数无效
【问题讨论】: