Hi,

Im'trying to read gmail contacts from my GAE APP. So the following
class works fine at desktop app, but when i call "getEmails" method at
my servlet a excpetion occurs. Seems like im not allowed to do it.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.kshare.control;

import com.google.gdata.client.contacts.*;
import com.google.gdata.data.contacts.*;

import com.google.gdata.data.contacts.ContactFeed;

import com.google.gdata.data.contacts.ContactEntry;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author malacma
 */
public class ContactsControlUtil {

    public static List<String> getEmails(String user, String senha)
throws MalformedURLException, AuthenticationException, IOException,
ServiceException {
        URL feedUrl = new URL("https://www.google.com/m8/feeds/
contacts/default/full");
        ContactsService service = new ContactsService("Google-
contactsExampleApp-1");
        service.setUserCredentials(user, senha);
        ContactFeed cf = service.getFeed(feedUrl, ContactFeed.class);


        List<String> lEmails = new ArrayList<String>();
        for (ContactEntry ce : cf.getEntries()) {
            //System.out.print(ce.toString());
            List<Email> lEmail = ce.getEmailAddresses();
            for (Email em : lEmail) {
                lEmails.add(em.getAddress());
            }
        }
        return lEmails;

    }
    public static  void main(String args[]) throws
MalformedURLException, AuthenticationException, IOException,
ServiceException{
        System.out.print(getEmails("mala...@gmail.com",
"XXXXXXXXXXXX"));
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to