<?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?Спасибо.
дерево 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>
$width = $xml->channel->item->children('gphoto',true)->width; $height = $xml->channel->item->children('gphoto',true)->height;
Мне проще удалить пространства имен при работе с фидами Google API.
$response = str_replace('gphoto:', '', $response);