10 defined(
'JPATH_PLATFORM') or die;
31 parent::__construct($options, $auth);
33 if (isset($this->auth) && !$this->auth->getOption(
'scope'))
35 $this->auth->setOption(
'scope',
'https://picasaweb.google.com/data/');
49 public function listAlbums($userID =
'default')
51 if ($this->isAuthenticated())
53 $url =
'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID);
54 $jdata = $this->query($url, null, array(
'GData-Version' => 2));
55 $xml = $this->safeXML($jdata->body);
57 if (isset($xml->children()->entry))
61 foreach ($xml->children()->entry as $item)
69 throw new UnexpectedValueException(
"Unexpected data received from Google: `{$jdata->body}`.");
93 public function createAlbum($userID =
'default', $title =
'', $access =
'private', $summary =
'', $location =
'', $time =
false, $keywords = array())
95 if ($this->isAuthenticated())
97 $time = $time ? $time : time();
98 $title = $title !=
'' ? $title : date(
'F j, Y');
99 $xml =
new SimpleXMLElement(
'<entry></entry>');
100 $xml->addAttribute(
'xmlns',
'http://www.w3.org/2005/Atom');
101 $xml->addChild(
'title', $title);
102 $xml->addChild(
'summary', $summary);
103 $xml->addChild(
'gphoto:location', $location,
'http://schemas.google.com/photos/2007');
104 $xml->addChild(
'gphoto:access', $access);
105 $xml->addChild(
'gphoto:timestamp', $time);
106 $media = $xml->addChild(
'media:group',
'',
'http://search.yahoo.com/mrss/');
107 $media->addChild(
'media:keywords', implode($keywords,
', '));
108 $cat = $xml->addChild(
'category',
'');
109 $cat->addAttribute(
'scheme',
'http://schemas.google.com/g/2005#kind');
110 $cat->addAttribute(
'term',
'http://schemas.google.com/photos/2007#album');
112 $url =
'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID);
113 $jdata = $this->query($url, $xml->asXML(), array(
'GData-Version' => 2,
'Content-type' =>
'application/atom+xml'),
'post');
115 $xml = $this->safeXML($jdata->body);
135 public function getAlbum($url)
137 if ($this->isAuthenticated())
139 $jdata = $this->query($url, null, array(
'GData-Version' => 2));
140 $xml = $this->safeXML($jdata->body);