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("
us...@domain.com",
"Password", "cp");
$gdata = new Zend_Gdata($client);
$query = new Zend_Gdata_Query('
http://www.google.com/m8/feeds/contacts/
$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 <
darie.nico...@gmail.com> 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)" <
j...@google.com> 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)" <
j...@google.com> 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("
u...@domain.com",
> > > "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.