1

我正在尝试解析来自 bandintown 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}]

当我尝试回显纬度和经度时,我只会收到错误消息。

提前致谢!

4

0 回答 0