Friday, May 25, 2012

User Photo Not Visible On Site From Rest API In Apex Salesforce

Hi All ,
I was accessing the photourl through site !

"photo": {
        "largePhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/F",
        "photoVersionId": "729D00000000BDV",
        "smallPhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/T"

Now if we expose these photo url on visualforce page would render properly but if we try to get the same of public site these photo url does not exist because session does not maintain .Images look like burst and does not show properly.

So what we can do , we can append either oauth_token or sessionid at the last of the photourl as a parameter. 
Let say our photo url is "largePhotoUrl": 


so we need to append the oauth_token like :

largePhotoUrl": "https://instance_name/profilephoto/729D00000000BDV/F'?oauth_token=00DV0000004RJpB!ARMAQFwrXxu7t6DAjWcseeWxXTo9UtSh4xZbrWJqHRnCulQ16yKqq97wIWIREdPtKfQ7BcFffyD9Y43MVBfa4hmHaPLfkT6C';
Now you can access the image as public with the help of oauth_token . Thanks


  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:

  2. Salesforce is the cloud based tool which is used by most of the professional who do CRM. Salesforce is the cost effective tool.
    salesforce training institute in chennai|salesforce training institutes in chennai|salesforce course in chennai

  3. Nowadays, most of the businesses rely on cloud based CRM tool to power their business process. They want to access the business from anywhere and anytime. In such scenarios, salesforce CRM will ensure massive advantage to the business owners. Salesforce Training | Salesforce Training in Chennai

  4. This blog having the details of Processes running. The way of runing is explained clearly. The content quality is really great. The full document is entirely amazing. Thank you very much for this blog.
    Hadoop Training in Chennai

  5. This is Great and very useful advice with in this post. Thank you.
    mvc training in chennai

  6. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    iOS Training in Chennai

  7. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind.
    Very interesting and useful about salesforce apex
    Best Salesforce training in Gurgaon