1
我想從Flickr網站檢索數據,運行php代碼後,它給了我兩個錯誤。 1)未能加載外部實體 2)的foreach()提供參數無效未能加載外部實體(flickr網站)
查找下面的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="[email protected]" secret="cafd39b094" server="219" farm="1" title="Seeing the Sun Going Down" ispublic="1" isfriend="0" isfamily="0"/>
<photo id="5858562848" owner="[email protected]" secret="19c083483f" server="5154" farm="6" title="Lords - June 2011 - E v SL - Rangana Herath Delivers" ispublic="1" isfriend="0" isfamily="0"/>
</photos>
</rsp>
我試過你的第二個建議,但它返回了一個空白頁 – akinboj 2012-03-07 16:46:07
看到我編輯的答案,你沒有正確解析返回的XML。 – xato 2012-03-07 16:56:10