0

嗨,我一直在尝试以 JSON 格式提取数据。这是我的代码

$resourse_url  = 'http://www.livepicly.com/app/api.php?method=list_vendor_name';
$json_data = file_get_contents($resourse_url);
$json_output = json_decode($json_data, TRUE);

$vendor = $json_output['vendor_name'][1];

echo "<pre>";
print_r($vendor);
exit(1);

但是,当我运行代码时,它不会返回任何内容。当我尝试通过 Firefox 访问源 URL 时,它会询问我将 JSON 数据保存为 *.php 的位置,但是当我从 Chrome 访问源 URL 时,它会正常显示 JSON 数据。

我必须在这里做什么?谁能指出我的解决方案?谢谢

4

1 回答 1

0

在http://jsonformatter.curiousconcept.com/上运行返回的 json

{
   "result":[
      {
         "vendor_id":"726",
         "vendor_name":"Scusa"
      },
      {
         "vendor_id":"519",
         "vendor_name":"Emilie French Restaurant and Bar"
      },
      {
         "vendor_id":"482",
         "vendor_name":"Cassis French Fine Dining"
      },
      {
         "vendor_id":"435",
         "vendor_name":"Asuka Japanase Dining"
      },
      {
         "vendor_id":"12050",
         "vendor_name":"Taipan"
      },
      {
         "vendor_id":"12061",
         "vendor_name":"Social House"
      },
      {
         "vendor_id":"12103",
         "vendor_name":"Harum Manis Indonesian Restaurant"
      },
      {
         "vendor_id":"12193",
         "vendor_name":"Nanny\'s Pavillion (Central Park)"
      },
      {
         "vendor_id":"12272",
         "vendor_name":"Bistro Baron"
      },
      {
         "vendor_id":"20704",
         "vendor_name":"Kitchenette (Central Park)"
      },
      {
         "vendor_id":"21217",
         "vendor_name":"Kitchenette (Plaza Indonesia)"
      },
      {
         "vendor_id":"29859",
         "vendor_name":"Momento Restaurant And Bar"
      },
      {
         "vendor_id":"31055",
         "vendor_name":"Tortuga Kitchen And Bar"
      },
      {
         "vendor_id":"31056",
         "vendor_name":"Tuck And Chug"
      },
      {
         "vendor_id":"31060",
         "vendor_name":"AUROZ Gourmet Grill"
      }
   ]
}

它在这一行发现无效字符

"vendor_name":"Nanny\'s Pavillion (Central Park)"
于 2013-05-27T10:18:21.177 回答