Hello,

You can use the "group" query parameter to request contacts belonging to a
specific group ID:
  http://code.google.com/apis/contacts/docs/3.0/reference.html#Parameters

Best,
Alain

On Sat, Nov 12, 2011 at 12:11 AM, Samuel Bolduc <[email protected]>wrote:

> Hi,
>
> I'm starting with Google APIs, and I'm trying to get all the contacts from
> a group, but so far I didn't succeed. The best I can do is get a list of
> the groups. Here's the code :
>
> $query = new Zend_Gdata_Query(
>>
>>         "https://www.google.com/m8/feeds/groups/default/full";);
>>
>>       $feed = $gdata->getFeed($query);
>>
>>
>>
> With this (https://www.google.com/m8/feeds/groups/default/full), I get
> the list of groups. With
> https://www.google.com/m8/feeds/contacts/default/full, I get all the
> contacts. But I can't figure out how to get contacts from a particular
> group. I tried
> https://www.google.com/m8/feeds/groups/default/base/782cb7b30e3c8be5(group 
> id) but it gives me an error
> **"ERROR:No root elem**ent". Can you point what's wrong to me? Thanks!
>
>  Here's the complete code I took and edited for this :
>
>     <?php
>     // load Zend Gdata libraries
>     require_once 'Zend/Loader.php';
>     Zend_Loader::loadClass('Zend_Gdata');
>     Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
>     Zend_Loader::loadClass('Zend_Http_Client');
>     Zend_Loader::loadClass('Zend_Gdata_Query');
>     Zend_Loader::loadClass('Zend_Gdata_Feed');
>
>     // set credentials for ClientLogin authentication
>     $user = "[email protected]";
>     $pass = "xxxxxxxx";
>
>     try {
>       // perform login and set protocol version to 3.0
>       $client = Zend_Gdata_ClientLogin::getHttpClient(
>         $user, $pass, 'cp');
>       $gdata = new Zend_Gdata($client);
>       $gdata->setMajorProtocolVersion(3);
>
>       // perform query and get result feed
>       $query = new Zend_Gdata_Query(
>         "
> https://www.google.com/m8/feeds/groups/default/base/782cb7b30e3c8be5";);
>       $feed = $gdata->getFeed($query);
>
>       // display title and result count
>       ?>
>
>       <h2><?php echo $feed->title; ?></h2>
>       <div>
>       <?php echo $feed->totalResults; ?> contact(s) found.
>       </div>
>
>       <?php
>       // parse feed and extract contact information
>       // into simpler objects
>       $results = array();
>       foreach($feed as $entry){
>         $xml = simplexml_load_string($entry->getXML());
>         $obj = new stdClass;
>         $obj->id = (string) $entry->id;
>         $obj->name = (string) $entry->title;
>         $obj->orgName = (string) $xml->organization->orgName;
>         $obj->orgTitle = (string) $xml->organization->orgTitle;
>
>         foreach ($xml->email as $e) {
>           $obj->emailAddress[] = (string) $e['address'];
>         }
>
>         foreach ($xml->phoneNumber as $p) {
>           $obj->phoneNumber[] = (string) $p;
>         }
>         foreach ($xml->website as $w) {
>           $obj->website[] = (string) $w['href'];
>         }
>
>         $results[] = $obj;
>       }
>     } catch (Exception $e) {
>       die('ERROR:' . $e->getMessage());
>     }
>     ?>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://code.google.com/apis/contacts/community/forum.html
>



-- 
Alain Vongsouvanh | Developer Programs Engineer

-- 
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html

Reply via email to