2

I have to access a chatter photo in Sites VF page using partner portal. I know that chatter photo cant be accessed by partner portal users. Is there any work around?

I saw this link which says that we can implement using oauth token. http://blogs.developerforce.com/developer-relations/2011/03/accessing-chatter-user-pics.html

Here is my photo url :- https://c.cs11.content.force.com/profilephoto/729G00000008q3L/F

How do I obtain the oauth token? I just created a remote access with call back url as :- https://app.example.com/oauth/callback and these two keys got generated automatically :-

Consumer Key :-

[deleted]

Consumer Secret :-

[deleted]

and here is my sites url (integrated with partner portal):- http://xy.xyz.cs11.force.com/MySite/

Can You please tell me what I need to append in my url and which url (c.cs11.content or my site url?) and what token should i append to see my photo in my site?

3

Finally I found the solution. Instead of using Oauth, I did the same in a different way.

  1. Created one custom object with a lookup to user.
  2. Created a field to save the 'FullPhotoURL' of that user
  3. Got the image as blob and saved as an attachment to this custom object.

From my sites page, I queried this Custom object and showed the image from the attachment

  • How did you get the image as blob? (step 3). Salesforce will not let me run HTTP request within triggers. – Hairgami_Master May 14 '13 at 19:39
1

There is better solution using chatter connect API.

public String getUserPhotoURL(String UserId) {
        ConnectApi.Photo ph =  ConnectApi.ChatterUsers.getPhoto(null, UserId);
        return ph.fullEmailPhotoUrl;
} 

Read more in my blog: http://sforcenotes.blogspot.com/2015/10/solution-to-display-salesforce-user.html

0

http://cloudyworlds.blogspot.in/2012/09/cloudy-using-poster-mozilla-tool-to-get.html

This will give you how to obtain access token or Oauth token from SFDC .Then you can proceed as sandeep pointed in previous blog.

Also since sandeep mentions even session id can do, you may use userinfo.getSessionId() method .Refer Userinfo class of apex.follow the below link http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

Adding further here is another post that may help you

http://salesforceapexcodecorner.blogspot.in/2012/05/user-photo-not-visible-on-forcecom-site.html

  • Thanks for your reply Mohith. The post that you have provided will be useful to get the Oauth from an external application. But I need to get the same in the apex. – Priyanka Oct 5 '12 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.