Hello, What kind of error do you get if the contact doesn't have a picture? It should work the same way, the only difference is to ignore the "If-Match" header. Also, please version 3.0 instead of version 2.0 of the API.
Best, Alain On Wed, Apr 25, 2012 at 2:24 PM, Jean-Louis <[email protected]> wrote: > I've several scripts for updating the pix of a contact. Below is the one I > use. It works just fine. However, it works only when the contact already > has a pix stored. > Do you have another script for adding a pix, and not replacing one? or do > you know what to modify to mine? > Thanks so much for your help. > > > > $client = Zend_Gdata_ClientLogin::getHttpClient(USER,PASS, 'cp'); > $gdata = new Zend_Gdata($client, 'Lcf'); > $gdata->setMajorProtocolVersion(2); > > $entryLink = ' > http://www.google.com/m8/feeds/contacts/****%40gmail.com/full/40...d1'; > $photoLinkRel = 'http://schemas.google.com/contacts/2008/rel#photo'; > > $entry = $gdata->getEntry($entryLink); > $photoLink= $entry->getLink($photoLinkRel)->getHref(); > $photoResponse = $gdata->get($photoLink); > $newPhotoContent = file_get_contents($pix); > $gdata->put( $newPhotoContent, $photoLink, null, 'image/*', > array('If-Match' => $photoResponse->getHeader('ETag')) ); > > -- > 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
