can not get <gd:extendedProperty> by using google API

137 views
Skip to first unread message

Amao Xu

unread,
May 18, 2012, 11:19:44 AM5/18/12
to google-co...@googlegroups.com
Hi everyone,

i am using google-API (in PHP) to retrieve  contacts information from google account.
But i can not retrieve <gd:extendedProperty> from account. I thought, if i am using "full", all of properties should be returned?
I have already read the reference many times, still can not find a single clue, why i can not get the custom-properties.
I preciate, if somebody could provide some advice for me. Thanks a lot.

if ($client->getAccessToken()) {
   
    $head = array();
    $head[0]="GET /m8/feeds/contacts/default/full/676d81880c24a582";
    $head[1]="If-Match: *";
    $head['content-type']='application/atom+xml';
    $head['charset']='UTF-8';
   
    $req = new apiHttpRequest("https://www.google.com/m8/feeds/contacts/default/full/676d81880c24a582");
    $req->setRequestMethod('GET');
    $req->setRequestHeaders($head);
    $val = $client->getIo()->authenticatedRequest($req);
 
 

Gavin Johnson

unread,
May 18, 2012, 5:57:25 PM5/18/12
to google-co...@googlegroups.com
Hi Amao,

Couple of things you might want to check.

Firstly you need to ask for version 3 as the extendedProperties are
not returned. Here's a c-n-p from some working code.

function get($xmlfile) {
try {
@$feed = simplexml_load_file($xmlfile. '&v=3.0');
if ($feed === FALSE) {
throw new Exception(file_get_contents($xmlfile));
}
} catch (Exception $e) {
return array('error' => true, 'payload' => $e->getMessage());
}
return array('error' => false, 'payload' => $xmlData);
}

Next thing to look for is something to tell simplexml that you want to
use the gd namespace. Another example:

$this->nsGd = $xmlData->children('http://schemas.google.com/g/2005');
...
$this->email = @(string)$this->nsGd->email->attributes()->address;
...
foreach ($this->nsGd->extendedProperty as $x) {
if ($x->attributes()->name == 'ethnicity') {
$this->ethnicity = $x->attributes()->value;
}
}

Hope that helps.

Gavin
> --
> 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
> google-co...@googlegroups.com
> To unsubscribe from this group, send email to
> google-contacts...@googlegroups.com
> For more options, visit this group at
> http://code.google.com/apis/contacts/community/forum.html



--
ga...@fnarg.net will expire please update your records
Reply all
Reply to author
Forward
0 new messages