+ Start a Discussion

How to show user profile image in a third-party web app using rest API?

Hi, I am developing a website for chatter users. I want to show their profile image regardless whether the user has an active session to salesforce or not.

After reading http://blogs.developerforce.com/developer-relations/2011/03/accessing-chatter-user-pics.html, I tried  "photolUrl" + "?oauth_token=" + access_token for getting the photo.

Specifically, the "photoUrl" includes the one returned from a "feedItem",  and "largePhotoUrl" "smallPhotoUrl" from a "userId/photo".

I tried to put the combined URL directly in html like this:

<img src=combinedURL> </img>


I tried as well as to download the image first in the server and then serve it to the user. The following java code is used in a servlet:


URL url = new URL(photoUrl + "?oauth_token=" + this.getAccessToken());
BufferedInputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("image.png"));
int i;
while ((i = in.read()) != -1) {

 However, none of the above gives correct result. The download code works on google logo image, but it doesn't work on the combined url

 Can anybody help me?