Hi,

I'm trying to update a profile picture using the Java Profiles API, but when 
I run this code, it updates the admin's(whose credentials I'm using to 
authenticate) photo, not the photo of the user I'm targeting:

    Link photoLink = null;
    URL photoUrl = null;
    String userName = "exampleAdmin";
    String password = "examplePassword";
    ContactsService service = new 
ContactsService("Google-contactsExampleApp-3");
    
    service.setUserCredentials(userName, password);
    
    ProfileEntry entry = service.getEntry(new 
URL("https://www.google.com/m8/feeds/profiles/domain/example.com/full/john.smith";),
     ProfileEntry.class);
    
    if (entry != null)
    {
     System.out.println("not null");
     if (entry.hasEmailAddresses()) {
     List<Email> addressList = entry.getEmailAddresses();
     for (Iterator<Email> iter=addressList.iterator(); iter.hasNext(); ) {
     Email email = iter.next();
     if (email.getAddress().equals("[email protected]")) {
     System.out.println("Found record");
     
     byte[] buffer = new byte[4096];
     
     FileInputStream in = new FileInputStream("image.jpg");
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     
     for (int read = 0; (read = in.read(buffer)) != -1;
             out.write(buffer, 0, read));
     
     photoLink = entry.getContactPhotoLink();
     
             photoUrl = new URL(photoLink.getHref());
             GDataRequest request = 
service.createRequest(GDataRequest.RequestType.UPDATE,
                 photoUrl, new ContentType("image/jpeg"));
             request.setEtag(photoLink.getEtag());
             OutputStream requestStream = request.getRequestStream();
             requestStream.write(buffer);
             request.execute();
        
             return;
     }
     }
       }
    }

-- 
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

Reply via email to