10 defined(
'JPATH_PLATFORM') or die;
43 $this->options = isset($options) ? $options :
new JRegistry;
54 public function authenticate()
56 return $this->auth->authenticate();
66 public function isAuthenticated()
68 return $this->auth->isAuthenticated();
81 protected static function safeXML($data)
85 return new SimpleXMLElement($data, LIBXML_NOWARNING | LIBXML_NOERROR);
89 throw new UnexpectedValueException(
"Unexpected data received from Google: `$data`.");
105 protected function listGetData($url, $maxpages = 1, $token = null)
109 if (strpos($url,
'&') && isset($token))
111 $qurl .=
'&pageToken=' . $token;
113 elseif (isset($token))
115 $qurl .=
'pageToken=' . $token;
117 $jdata = $this->query($qurl);
118 $data = json_decode($jdata->body,
true);
120 if ($data && array_key_exists(
'items', $data))
122 if ($maxpages != 1 && array_key_exists(
'nextPageToken', $data))
124 $data[
'items'] = array_merge($data[
'items'], $this->listGetData($url, $maxpages - 1, $data[
'nextPageToken']));
126 return $data[
'items'];
134 throw new UnexpectedValueException(
"Unexpected data received from Google: `{$jdata->body}`.");
150 protected function query($url, $data = null, $headers = null, $method =
'get')
152 return $this->auth->query($url, $data, $headers, $method);
164 public function getOption($key)
166 return $this->options->get($key);
179 public function setOption($key, $value)
181 $this->options->set($key, $value);