Hello Chris, Can you print the data returned by the API ($entryResult)? The API always returns the entry it created or updated and this is the way to check that everything went fine. If the groupMembershipInfo field doesn't appear, that would mean something went wrong and the API didn't process this part of your entry.
Also, can you print the XML data you are sending too to make sure you are sending something valid? Once you get the XML, you can try sending it to the API by using OAuth playground and modifying it until it works: http://code.google.com/apis/gdata/articles/oauth.html Last thing, you shouldn't have to set the "xmlns" attribute to your $grp field. Best, Alain On Tue, Jun 14, 2011 at 11:42 AM, Chris <[email protected]> wrote: > I've been looking into this quite a lot but I haven't been able to add > a contact to a custom contact group. It doesn't come up with an error > or anything it just doesn't work. I'm using Zend and PHP. I'm pretty > new at this and could be making a stupid mistake. > Help would be much appreciated =) > Thanks my code is below > > <?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 = "password"; > > // 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); > > $doc = new DOMDocument(); > $doc->formatOutput = true; > $entry = $doc->createElement('atom:entry'); > $entry->setAttributeNS('http://www.w3.org/2000/xmlns/' , 'xmlns:atom', > 'http://www.w3.org/2005/Atom'); > $entry->setAttributeNS('http://www.w3.org/2000/xmlns/' , 'xmlns:gd', > 'http://schemas.google.com/g/2005'); > $entry->setAttributeNS('http://www.w3.org/2000/xmlns/' , > 'xmlns:gContact', 'http://schemas.google.com/g/2008'); > $doc->appendChild($entry); > > $cat = $doc->createElement('atom:category'); > $cat->setAttribute('scheme', 'http://schemas.google.com/g/2005#kind'); > $cat->setAttribute('term', 'http://schemas.google.com/contact/ > 2008#contact'); > $entry->appendChild($cat); > > // add name element > $name = $doc->createElement('gd:name'); > $entry->appendChild($name); > $fullName = $doc->createElement('gd:fullName', 'Jack Frost'); > $name->appendChild($fullName); > > // add email element > $email = $doc->createElement('gd:email'); > $email->setAttribute('address' ,'[email protected]'); > $email->setAttribute('rel' ,'http://schemas.google.com/g/2005#home'); > $entry->appendChild($email); > > // add Group name element > $grp = $doc->createElement('gContact:groupMembershipInfo'); > $grp->setAttribute('xmlns', 'http://schemas.google.com/contact/ > 2008'); > $grp->setAttribute('deleted' ,'false'); > $grp->setAttribute('href' ,'http://www.google.com/m8/feeds/groups/hi > %40agency.com/base/groupidnumber > '); > $entry->appendChild($grp); > > // insert entry > $entryResult = $gdata->insertEntry($doc->saveXML(), 'http:// > www.google.com/m8/feeds/contacts/default/full'); > ?> > > -- > 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 -- 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
