从 Twitter 搜索 API 解析 trends.json
正在努力解析来自 http://api.twitter.com/1/trends/ 的 JSON 响应current.json
使用 foreach ($json_output->trends[0] as $trend ) { echo $趋势->名称; }
stdClass Object ( [trends] => stdClass Object ( [2011-05-03 17:43:42] => Array ( [0] => stdClass Object ( [query] => TeAmamosLuanS [events] => [promoted_content] => [name] => TeAmamosLuanS ) [1] => stdClass Object ( [query] => CASEY RULES [events] => [promoted_content] => [name] => CASEY RULES ) [2] => stdClass Object ( [query] => Rashard Mendenhall [events] => [promoted_content] => [name] => Rashard Mendenhall ) [3] => stdClass Object ( [query] => Alexandre Nardoni [events] => [promoted_content] => [name] => Alexandre Nardoni ) [4] => stdClass Object ( [query] => Henrique Capriles [events] => [promoted_content] => [name] => Henrique Capriles ) [5] => stdClass Object ( [query] => LivroRestart [events] => [promoted_content] => [name] => LivroRestart ) [6] => stdClass Object ( [query] => TeamXtina [events] => [promoted_content] => [name] => TeamXtina ) [7] => stdClass Object ( [query] => Howard Webb [events] => [promoted_content] => [name] => Howard Webb ) [8] => stdClass Object ( [query] => Camp Nou [events] => [promoted_content] => [name] => Camp Nou ) [9] => stdClass Object ( [query] => MTV Movie Awards [events] => [promoted_content] => [name] => MTV Movie Awards ) ) ) [as_of] => 1304444622 )
请帮助数组/对象解析。谢谢。
Struggling to parse this JSON response from http://api.twitter.com/1/trends/current.json
using foreach ($json_output->trends[0] as $trend )
{
echo $trend->name;
}
stdClass Object ( [trends] => stdClass Object ( [2011-05-03 17:43:42] => Array ( [0] => stdClass Object ( [query] => TeAmamosLuanS [events] => [promoted_content] => [name] => TeAmamosLuanS ) [1] => stdClass Object ( [query] => CASEY RULES [events] => [promoted_content] => [name] => CASEY RULES ) [2] => stdClass Object ( [query] => Rashard Mendenhall [events] => [promoted_content] => [name] => Rashard Mendenhall ) [3] => stdClass Object ( [query] => Alexandre Nardoni [events] => [promoted_content] => [name] => Alexandre Nardoni ) [4] => stdClass Object ( [query] => Henrique Capriles [events] => [promoted_content] => [name] => Henrique Capriles ) [5] => stdClass Object ( [query] => LivroRestart [events] => [promoted_content] => [name] => LivroRestart ) [6] => stdClass Object ( [query] => TeamXtina [events] => [promoted_content] => [name] => TeamXtina ) [7] => stdClass Object ( [query] => Howard Webb [events] => [promoted_content] => [name] => Howard Webb ) [8] => stdClass Object ( [query] => Camp Nou [events] => [promoted_content] => [name] => Camp Nou ) [9] => stdClass Object ( [query] => MTV Movie Awards [events] => [promoted_content] => [name] => MTV Movie Awards ) ) ) [as_of] => 1304444622 )
Please help with array/object parsing. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以使用类似的东西:
输出:
You could use something like:
Output: