Nope this didnt worked also, something is not okay, can you see if there is a piece of code that works for sure when trying to remove a contact from a specific group ?!
Thanks a lot. On Apr 7, 12:02 pm, "Julian (Google)" <[email protected]> wrote: > Hi, > > Maybe you can try the following, it finds the contacts by its title > and removes the appropriate groupMembershipInfo for a given GroupID: > > <?php > $clientLibraryPath = '/var/www/contacts/Zend'; > $oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . > $clientLibraryPath); > > require_once 'Loader.php'; > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); > Zend_Loader::loadClass('Zend_Gdata'); > Zend_Loader::loadClass('Zend_Gdata_Query'); > > // Using Client Login > $client = Zend_Gdata_ClientLogin::getHttpClient("[email protected]", > "Password", "cp"); > $gdata = new Zend_Gdata($client); > $query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/ > user%40domain.com/full'); > $feed = $gdata->getFeed($query,Zend_Gdata_App_Feed); > > $groupId = 'http://www.google.com/m8/feeds/groups/user%40domain.com/ > base/7d60cf6309868fc6'; > $contactTitle = 'Title'; > > foreach ($feed->getEntry() as $entry ) { > if ( $entry->getTitle() == $contactTitle ) { > $newExtensionElements = array(); > foreach ( $entry->getExtensionElements() as $extensionElement ) { > $domElement = $extensionElement->getDom(); > if ( !($domElement->tagName == 'groupMembershipInfo' and > $domElement->getAttribute( 'href' ) == $groupId )) { > array_push($newExtensionElements, $extensionElement ); > } > } > $entry->setExtensionElements( $newExtensionElements ); > $entry->save(); > }} > > ?> > > -Julian > > On Apr 6, 9:47 pm, darie nicolae <[email protected]> wrote: > > > Thanks Julian, > > > About removing a specific contact name from a group. the code above > > was for removing an entire group by a specific group title, what i > > want is to remove a specific contact name from a group X : > > > I did something like this, but it doesnt work : > > > $query = new Zend_Gdata_Query("http://www.google.com/m8/feeds/ > > contacts/ > > varzariu.nicolae%40gmail.com/full/?group=" . $grouplink . '&v=2'); > > $feed = $gdata->getFeed( $query ); > > > foreach ($feed->getEntry() as $entry ) { > > > echo $entry->getTitle()->getText() . '<br>'; > > > if ( $entry->getTitle()->getText() == "contact title") > > $entry->delete(); > > > } > > > $grouplink is the link of the group id. > > the echo $entry->getTitle()->getText() displays the contact title, > > but when i do $entry->deleteit doesnt work. > > > Thanks and sorry for asking so many questions. > > > On Apr 6, 6:53 pm, "Julian (Google)" <[email protected]> wrote: > > > > Hi, > > > > Also, about the Phone Number and the Notes: > > > > $entry->setContent( new Zend_Gdata_App_Extension_Content( 'New NOTE', > > > 'text')); > > > $extension = new Zend_Gdata_App_Extension_Element('phoneNumber', null, > > > 'http://schemas.google.com/g/2005'); > > > $extension->setText('555-6789'); > > > $attribures1 = array(); > > > $attributes1['rel'] = array('namespaceUri'=>null,'name'=>'rel', > > > 'value' => 'http://schemas.google.com/g/2005#home'); > > > $extension->setExtensionAttributes($attributes1); > > > array_push( $extensionElements, $extension ); > > > $entry->setExtensionElements( $extensionElements ); > > > $entry->save(); > > > > The Relation for the phone number can be one of the > > > following:http://code.google.com/apis/gdata/elements.html#gdPhoneNumber > > > > Cheers, > > > Julian > > > > On Apr 6, 5:16 pm, "Julian (Google)" <[email protected]> wrote: > > > > > Hi, > > > > > Similar to my previous post (http://groups.google.com/group/google- > > > > contacts-api/browse_thread/thread/55ca554133da51ac), just by changing > > > > the feed to a Groups feed. You candeletea whole Group(Entry) using > > > > its Title like this: > > > > > <?php > > > > $clientLibraryPath = '/var/www/contacts/Zend'; > > > > $oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . > > > > $clientLibraryPath); > > > > > require_once 'Loader.php'; > > > > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); > > > > Zend_Loader::loadClass('Zend_Gdata'); > > > > Zend_Loader::loadClass('Zend_Gdata_Query'); > > > > > // Using Client Login > > > > $client = Zend_Gdata_ClientLogin::getHttpClient("[email protected]", > > > > "Password", "cp"); > > > > $gdata = new Zend_Gdata($client); > > > > $query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/groups/ > > > > user%40domain.com/full'); > > > > $feed = $gdata->getFeed($query,Zend_Gdata_App_Feed); > > > > > foreach ($feed->getEntry() as $entry ) { > > > > if ( $entry->getTitle()->getText() == "GROUP Title" ) > > > > $entry->delete(); > > > > > } > > > > > ?> > > > > > If you have the ID of the Group, you can get the entry directly and > > > >deleteit without iterating over the whole list. > > > > > Cheers, > > > > -Julian > > > > > On Apr 6, 3:01 pm, darie nicolae <[email protected]> wrote: > > > > > > Hey Julian, the code Andrew wrote above it was for removing a whole > > > > > group, the code you said to remove all contacts from a group actually > > > > > it didnt worked, it added a duplicate of the last contact instead and > > > > > nothing was deleted. > > > > > > Do you know what could be the problem? > > > > > > And also, how can i add phoneNumber and Notes to a contact when i add > > > > > it to a group ?( Talking about PHP ) > > > > > > Gracias! > > > > > > On Apr 6, 3:58 pm, "Julian (Google)" <[email protected]> wrote: > > > > > > > You're welcome Andrew. > > > > > > > Because other people asked about .NET, here is an example in C# > > > > > > (using > > > > > > the latest library). This removes a user from group using a group > > > > > > ID: > > > > > > > RequestSettings requestSettings = new RequestSettings("App-name", > > > > > > "[email protected]", "PASSWORD"); > > > > > > requestSettings.AutoPaging = true; > > > > > > ContactsRequest contactsRequest = new ContactsRequest > > > > > > (requestSettings); > > > > > > Uri uri = new Uri("http://www.google.com/m8/feeds/contacts/user > > > > > > %40domain.com/full/1"); // User's ID > > > > > > Contact contact = contactsRequest.Retrieve<Contact>(uri); > > > > > > > foreach (GroupMembership group in contact.GroupMembership){ > > > > > > // Group's ID > > > > > > if ( group.HRef.Equals( > > > > > > "http://www.google.com/m8/feeds/groups/user > > > > > > %40domain.com/base/6" )) { > > > > > > contact.GroupMembership.Remove( group ); > > > > > > contactsRequest.Update<Contact>(contact); > > > > > > break; > > > > > > } > > > > > > > } > > > > > > > On Apr 4, 4:43 am, andyjimmy <[email protected]> wrote: > > > > > > > > Worked a charm Julian. Thank you very much! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
