2014-09-22 81 views
0

任何機構都可以告訴我如何在羣組下創建一個Google聯繫人,例如我有一個羣組名稱系列,在此下面我想添加聯繫人。現在,我能夠創造接觸,但其下別人去下面的代碼我使用如何在Google中創建聯繫人羣組

ContactEntry contact = new ContactEntry(); 
contact.setTitle(new PlainTextConstruct("chetan")); 
contact.setContent(new PlainTextConstruct("sharma")); 

Email primaryMail = new Email(); 
primaryMail.setAddress("[email protected]"); 
primaryMail.setRel("http://schemas.google.com/g/2005#home"); 
primaryMail.setPrimary(true); 
contact.addEmailAddress(primaryMail); 

ExtendedProperty favouriteFlower = new ExtendedProperty(); 
favouriteFlower.setName("favourite flower"); 
favouriteFlower.setValue("daisy"); 
contact.addExtendedProperty(favouriteFlower); 


//URL postUrl = new URL("https://www.google.com/m8/feeds/contacts/defaults/full"); 
contact = service.insert(feedUrl, contact); 
GroupMembershipInfo groupMembershipInfo = new GroupMembershipInfo(false, "http://www.google.com/m8/feeds/groups/defaults/base/39eb8f59897bac4d"); 
//groupMembershipInfo 
contact.addGroupMembershipInfo(groupMembershipInfo); 

回答

0

我看到你將加入groupMembershipInfo前的接觸。如果要將組成員詳細信息添加到聯繫人,請移動此行「contact = service.insert(feedUrl,contact);」作爲代碼的最後一行。

有關更多詳細信息,請參閱此page

希望有幫助!

0

您可以執行以下方法,讓不同羣體的Atom ID在您的帳戶像我的聯繫人,家庭等

public static void printAllGroups(ContactsService myService) 
     throws ServiceException, IOException { 
     // Request the feed 
     URL feedUrl = new URL("https://www.google.com/m8/feeds/groups/[email protected]/full"); 
     ContactGroupFeed resultFeed = myService.getFeed(feedUrl, ContactGroupFeed.class); 

     for (ContactGroupEntry groupEntry : resultFeed.getEntries()) { 
     System.out.println("Atom Id: " + groupEntry.getId()); 
     System.out.println("Group Name: " + groupEntry.getTitle().getPlainText()); 
     } 
} 

這種方法對於家庭組的輸出將是這樣的:

的Atom標識:http://www.google.com/m8/feeds/groups/UR_EMAIL_ID/base/e

使用此URL,將聯繫人添加到家庭組

GroupMembershipInfo groupMembershipInfo = new GroupMembershipInfo(false, "http://www.google.com/m8/feeds/groups/UR_EMAIL_ID/base/e"); 
       contact.addGroupMembershipInfo(groupMembershipInfo);