Example #1
0
 public static function get_groups($api_key, $api_secret)
 {
     try {
         $api = new GoogleUtilityClient($api_key, $api_secret, 'HOSTED_OR_GOOGLE');
         $api->authenticate();
         $groups_response = $api->get('group/2.0/' . $api->domain);
         $entries = $groups_response['list']->getElementsByTagName('property');
         $groups = array();
         foreach ($entries as $entry) {
             if ($entry->getAttribute('name') == 'groupName') {
                 $groups[] = $entry->getAttribute('value');
             }
         }
     } catch (GoogleUtilityClientException $e) {
         throw new GoogleDomainException($e->getMessage());
     }
     return $groups;
 }
 public function __call($method, $args)
 {
     static $api_cumulative_time = 0;
     $time = microtime(true);
     // Initialize CURL
     self::$curl = curl_init();
     if (isset($args[0])) {
         $name = $args[0];
     }
     if (isset($args[1])) {
         $args = $args[1];
     }
     curl_setopt(self::$curl, CURLOPT_HTTPHEADER, array('Content-type: application/atom+xml', 'Authorization: GoogleLogin auth=' . $this->auth_token));
     if (preg_match('/^(http)/', $name, $matches) > 0) {
         $url = $name;
     } else {
         $url = 'https://apps-apis.google.com/a/feeds' . '/' . $name;
     }
     $response = $this->fetch($url, $method, $args);
     // If the response is a hash containing a key called 'error', assume
     // that an error occurred on the other end and throw an exception.
     if (isset($response['error'])) {
         throw new GoogleAuthenticationClientError($response['error'], $response['code']);
     } else {
         return $response['result'];
     }
 }