Friday, May 25, 2012

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


Hi All ,
I was accessing the photourl through force.com 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 force.com 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": 

"https://instance_name/profilephoto/729D00000000BDV/F",

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





54 comments:

  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

    ReplyDelete
  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

    ReplyDelete
  3. 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

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

    ReplyDelete
  5. 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



    ReplyDelete
  6. DIAC is offering Salesforce.com Training with on admin, developer, salesforce lightening, crm. Call @ +919310096831 for details on course fees, syllabus, placement facilities, batch timings, course duration.

    ReplyDelete
  7. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    salesforce crm online training

    ReplyDelete
  8. Thanks for sharing valuable information and it is useful for onlineitguru provides the best salesforce Online course Hyderabad

    ReplyDelete
  9. Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....


    Best Tableau online training in Hyderabad


    Tableau online training in Hyderabad


    Tableau training in Hyderabad

    ReplyDelete
  10. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.

    MEAN stack training in Chennai
    MEAN stack training in bangalore
    MEAN stack training in tambaram
    MEAN stack training in annanagar

    ReplyDelete
  11. I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
    python interview questions and answers
    python tutorials
    python course institute in electronic city

    ReplyDelete
  12. I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.
    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs interview questions and answers

    angularjs Training in marathahalli

    angularjs interview questions and answers

    angularjs-Training in pune

    ReplyDelete
  13. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    python course in pune
    python course in chennai
    python Training in Bangalore

    ReplyDelete
  14. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    rpa training in chennai |best rpa training in chennai|
    rpa training in bangalore | best rpa training in bangalore

    ReplyDelete
  15. Thank You For Sharing
    Yaaron Studios is one of the rapidly growing editing studios in Hyderabad. We are the best Video Editing services in Hyderabad. We provides best graphic works like logo reveals, corporate presentation Etc. And also we gives the best Outdoor/Indoor shoots and Ad Making services.
    video editors studio in hyderabad
    short film editors in hyderabad
    corporate video editing studio in hyderabad
    ad making company in hyderabad

    ReplyDelete
  16. This Information which you provided is very much useful for Agile Training Learners. Thank You for Sharing Valuable Information.sap s4 hana simple finance training in bangalore

    ReplyDelete
  17. Awesome post with lots of data and I have bookmarked this page for my reference. Share more ideas frequently.sap hr training in bangalore

    ReplyDelete
  18. Wow it is really wonderful and awesome thus it is veWow, it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.html training in bangalore

    ReplyDelete
  19. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.devops training

    ReplyDelete
  20. Thanks for sharing such an useful and informative stuff...

    Salesforce Developer Training

    ReplyDelete
  21. Really it was an awesome article about JAVA, very interesting to read.You have provided an nice article,Thanks for sharing.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  22. Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next
    python training in bangalore

    python training in hyderabad

    python online training

    python training

    python flask training

    python flask online training

    python training in coimbatore
    python training in chennai

    python course in chennai

    python online training in chennai


    ReplyDelete
  23. Very nice post here and thanks for it .I always like and such a super contents of these post.
    Excellent and very cool idea and great content of different kinds of the valuable information.
    Salesforce Training in Chennai

    Salesforce Online Training in Chennai

    Salesforce Training in Bangalore

    Salesforce Training in Hyderabad

    Salesforce training in ameerpet

    Salesforce Training in Pune

    Salesforce Online Training

    Salesforce Training


    ReplyDelete
  24. This post is so interactive and informative.keep update more information...
    RPA Training in Tambaram
    RPA Training in Chennai

    ReplyDelete
  25. i'm guiltless natured you take movement of to self-centeredness in your message. It makes you stand dependancy out from various assistant creators that can't maintain nonsensical environment content recollecting that you. Flip PDF Professional Full

    ReplyDelete
  26. You've got carried out a loud challenge upon this article. Its absolutely regulate and extremely qualitative. You've got even controlled to make it readable and smooth to make a get accord of of into. You've got a few specific writing adroitness. Thank you as a consequence lots. Syncios Data Recovery Free Download

    ReplyDelete
  27. Populated with sparkling lakes and also rivers, this location of Ireland is a real boaters’ heaven
    Selenium Training from UK
    Artificial Intelligence Training from UK
    <a href="https://viswaonlinetrainings.com/courses/aws-devops-online-training/>AWS Devops Training from UK</a>

    ReplyDelete