开发者

php simplexml node `gphoto:width`

<?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开发者_StackOverflow中文版->item->children('http://schemas.google.com/photos/2007');
    echo $gphoto->width;//nothing return  
    ?>

How to get picasa rss image width and height? Thanks.

the xml tree here:

  <?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>


$width  = $xml->channel->item->children('gphoto',true)->width;
$height = $xml->channel->item->children('gphoto',true)->height;


I find it easier to remove the namespaces when dealing with the google API feeds.

$response = str_replace('gphoto:', '', $response);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜