That works. Thank you very much!
On Sep 3, 8:43 am, "Julian (Google)" <[email protected]> wrote:
> Hi,
>
> Usually the HTTP 409 means that there is a conflict, maybe you are
> trying to insert a contact that already exists and you should update
> instead of inserting. Check that the email address does not exist
> before inserting a new contact.
>
> If for some reason you need to have a contact more than once, make
> sure that you use Contact v2, it allows multiple contacts with the
> same email address.
>
> Cheers,
> Julian.
>
> On Sep 3, 6:37 am, Randall <[email protected]> wrote:
>
> > I can't figure out why I'm getting HTTP status code 409. I'm trying to
> > add new contacts using Zend's Gdata class.
>
> > Here's my code:
>
> > <?php
> > require_once('Zend/Loader.php');
> > require_once('DeafForm.php');
>
> > Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
> > Zend_Loader::loadClass('Zend_Gdata_Gapps');
> > Zend_Loader::loadClass('Zend_Gdata_Query');
>
> > class BasicContact {
> > const SERVICE_NAME = "cp";
> > const APPLICATION_NAME = "basic_contact-test";
> > const USERNAME = "[email protected]"; //censored!
> > const PASSWORD = "fake-password"; //censored!
>
> > protected $httpclient;
> > protected $gdata;
> > protected $form;
> > protected $mystream;
>
> > public function __construct(){
> > $this->httpclient = Zend_Gdata_ClientLogin::getHttpClient
> > (self::USERNAME, self::PASSWORD, self::SERVICE_NAME, null,
> > self::APPLICATION_NAME);
> > $this->gdata = new Zend_Gdata($this->httpclient);
> > $this->mystream = "http://www.google.com/m8/feeds/contacts/
> > default/full";
> > }
>
> > public function addContact($form){
> > $entry = $this->gdata->newEntry();
> > $extensionElement = $entry->getExtensionElements();
> > $attributes = array();
>
> > //set contact's name
> > $entry->title = $this->gdata->newTitle($form-
>
> > >getSubmitterFirstName()." ".$form->getSubmitterLastName());
>
> > //generate email address
> > $extension = new Zend_Gdata_App_Extension_Element('email', null,
> > 'http://schemas.google.com/g/2005');
> > $attr['address'] = array('name' => 'address', 'value' =>
> > $emailaddy, 'namespaceUri' => null);
> > $attr['primary'] = array('name' => 'primary', 'value' => 'true',
> > 'namespaceUri' => null);
> > $attr['rel'] = array('name' => 'rel', 'value' => 'http://
> > schemas.google.com/g/2005#other', 'namespaceUri' => null);
> > $extension->setExtensionAttributes($attributes);
>
> > //update/add to contacts
> > $entry->setExtensionElements(array($extension));
> > $entryResult = $this->gdata->insertEntry($entry, $this->mystream);
> > }
> > }
>
> > ?>
>
> > And here's the error message:
> > Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with
> > message 'Expected response code 200, got 409 <?xml version='1.0'
> > encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom'
> > xmlns:gContact='http://schemas.google.com/contact/2008'
> > xmlns:batch='http://schemas.google.com/gdata/batch'xmlns:gd='http://
> > schemas.google.com/g/2005'><id>http://www.google.com/m8/feeds/contacts/
> > randalln.spam%40gmail.com/base/207d23568a39769d</
> > id><updated>2009-07-30T20:52:06.922Z</updated><category scheme='http://
> > schemas.google.com/g/2005#kind' term='http://schemas.google.com/
> > contact/2008#contact'/><title type='text'>Randall Noriega</title><link
> > rel='http://schemas.google.com/contacts/2008/rel#edit-photo'
> > type='image/*' href='http://www.google.com/m8/feeds/photos/media/
> > randalln.spam%40gmail.com/207d23568a39769d/1B2M2Y8AsgTpgAmY7PhCfg'/><link
> > rel='self' type='application/atom+xml' href='http://
>
> >www.google.com/m8/feeds/contacts/randalln.spam%40gmail.com/full/207d2...><link
> > rel='edit' type='application/atom+xml' href='http:/ in /usr/local/etc/
> > ZendGdata-1.8.4PL1/library/Zend/Gdata/App.php on line 699
>
> > I'm stumped at this point. Hope you guys can help solve my problem.
> > Thanks in advance, guys!
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Contacts API" 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://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---