<?php
$url = 'https://picasaweb.google.com/data/feed/api/user/114098057261214889617/albumid/5282805114683350385?alt=rss&kind=photo&max-results=1';
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$xml = simplexml_load_string($response);
$gphoto = $xml->channel->item->children('http://schemas.google.com/photos/2007');
echo $gphoto->width;//nothing return
?>
如何獲得picasa rss圖片的寬度和高度?謝謝。php simplexml節點`gphoto:width`
XML樹在這裏:
<?xml version="1.0" encoding="UTF-8" ?>
- <rss xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" version="2.0">
- <channel>
- <item>
...
<gphoto:width>1280</gphoto:width>
<gphoto:height>960</gphoto:height>
...
</item>
</channel>
</rss>
與PHP運行代碼5.3.3結果'1280'輸出爲我 –
還有,'的phpinfo()'輸出顯示,我有'的libxml2 2.7.8'用'XML命名空間支持active'爲它值什麼 –
@brian_d,沒有libxml2 2.7.8,所以我應該下載一個。 –