【发布时间】:2012-03-07 16:37:52
【问题描述】:
我正在尝试从 Flickr 网站检索数据,在运行 php 代码后它给了我两个错误。 1) 未能加载外部实体 2) 为 foreach() 提供的参数无效
找到下面的php代码:
<?php
$url = file_get_contents("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ff8c4c178209865b1ac5ee3f2d492de0&lat=51.5424&lon=-0.1734&radius=2&page=2&per_page=200&text=houses");
$xml = simplexml_load_file($url);
foreach ($xml->photo as $entry){
echo $entry->id;
echo $entry->owner;
echo $entry->title;
}
?>
请参阅下面的 xml 结构摘录:
<rsp stat="ok">
<photos page="2" pages="6" perpage="200" total="1199">
<photo id="476179009" owner="55662771@N00" secret="cafd39b094" server="219" farm="1" title="Seeing the Sun Going Down" ispublic="1" isfriend="0" isfamily="0"/>
<photo id="5858562848" owner="40837632@N05" secret="19c083483f" server="5154" farm="6" title="Lords - June 2011 - E v SL - Rangana Herath Delivers" ispublic="1" isfriend="0" isfamily="0"/>
</photos>
</rsp>
【问题讨论】: