Hello, Please have a look at the developer's guide as it explains how to delete<http://code.google.com/apis/contacts/docs/3.0/developers_guide.html#Deleting>a contact. If you don't want to delete a contact but remove this contact from a group, you should only update this contact by removing the reference to the group you want to remove.
Best, Alain On Wed, Sep 14, 2011 at 4:51 PM, saswat <[email protected]> wrote: > I am devloping one application which retrieves all contacts in Gmail for a > given UserId. In the retrieved page I have given on delete button. On > clicking this button it should delete the selected Contact from the list. So > i need to retrieve the contactid for all existing contacts. Moreover i have > to pass the contactid in the DeleteContact Servlet dynamically rather than > passing statically as i have done below in the code. So i wanted to know > > 1. How to retrieve all the contactid of existing contact? > 2. How to pass the id in the DeleteUrl dynamically? > *Here is my DeleteContact Servlet :-* > > import java.io.IOException; > import java.net.URL; > import java.util.logging.Level; > import java.util.logging.Logger; > > import javax.servlet.RequestDispatcher; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import com.google.gdata.client.contacts.ContactsService; > import com.google.gdata.client.http.GoogleGDataRequest; > import com.google.gdata.data.contacts.ContactEntry; > import com.google.gdata.util.PreconditionFailedException; > > @SuppressWarnings("serial") > > public class DeleteContact extends HttpServlet { > public static Logger logger = Logger.getLogger("Contact servlet"); > protected void doPost(HttpServletRequest req, HttpServletResponse resp) > throws ServletException, IOException { > doGet(req, resp); > > > System.out.println("1.code running"); > ContactsService myService = new ContactsService("ContactService"); > ContactEntry contact = null; > logger.log(Level.INFO, "Before Try block"); > try { > System.out.println("2.code running"); > System.setProperty(GoogleGDataRequest.DISABLE_COOKIE_HANDLER_PROPERTY, > "true"); > logger.log(Level.INFO, "Before setting the contactId Url"); > URL deleteUrl = new URL( > "http://www.google.com/m8/feeds/contacts/userId/base/22338a340ec88d12"); > > myService.setUserCredentials("UserId", "Password"); > contact = myService.getEntry(deleteUrl, ContactEntry.class); > > contact.delete(); > logger.log(Level.INFO, "After deleting the contact"); > System.out.println("3.code running"); > /*RequestDispatcher dispatcher = req.getRequestDispatcher("delete.jsp"); > if (dispatcher != null) > dispatcher.forward(req, resp);*/ > } catch (PreconditionFailedException e) { > e.printStackTrace(); > } > > catch (com.google.gdata.util.ServiceException e) { > > e.printStackTrace(); > > } > } > } > > > > > -- > 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
