Bandsintown Api用php解析json

时间:2013-02-07 18:41:24

标签: php json api parsing

我正在尝试解析来自bandsintown api的Json响应,但是我遇到了“可捕获的致命错误:类stdClass的对象无法转换为字符串”。

我的代码如下:

<?php
        //Get the list of events from the function
        $events = GetJsonFeed("http://api.bandsintown.com/example");

        //Loop through
        foreach ($events as $event) 
        { 
            echo "<h3> $event->title </h3>"; //title
            echo "<p> $event->formatted_datetime </p>";
            echo "<p> $event->venue->latitude </p>";
            echo "<p> $event->venue->longitude </p>";
            echo "<a href='$event->facebook_rsvp_url'>RSVP</a>"; //RSVP link
            echo "</div>";

        }

    ?>

json响应是这样的:

[{"artists":[{.....}],

"formatted_datetime":"Saturday, March 9, 2013 at 9:00pm",

"ticket_type":null,

"ticket_status":"unavailable",

"description":null,

"venue":{"latitude":"38.7166667","region":"14","longitude":"-9.1333333"},

"ticket_url":null}]

当我试图回显纬度和经度时,我只得到错误。

提前致谢!

0 个答案:

没有答案