You need to sign in to do that
Don't have an account?
NewToSitesCool
Chatter Photo API access
With the new API 20.0 version, seems like we get access to photos using SmallPhotoUrl and FullPhotoUrl, but seems like i need to have my salesforce session while accessing these images.
I have 2 requirements:
1. Way to download the image (get Image method)
2. Or an external shared image which can be accessed without salesforce session,
Is it possible with new API 20?
You need a session to access them (but, then you needed a session to get the URLs from the User sobject, so you should have one, right?)
Not exactly i will have session because we want photos to go to external system, plan was to give External System URL for photo and that photo can then be directly accessed.
Any Ideas around how this can be done without session?
Hi. You need a 'sid=sessionid' cookie in your cookiestore for the salesforce.com domain to retrieve the user image.
I'm actually having a problem finding User.SmallPhotoUrl etc in API 20. And the unsupported url (https://{instance}.salesforce.com/userphoto?id={ID}&v=1&s=T) for accessing photos is no longer working.
So.... is anyone else having a problem with User.SmallPhotoUrl et al in API 20? It's supposed to be in production right?
Are you using the Web API?
I'm using this as my endpoint but I'm not seeing the new fields in User:
https://login.salesforce.com/services/Soap/c/20.0
I will get a dump of my describe.
BTW mine is a developer account on na3 instance if that makes any diff.
After looking at a raw describeSObject(User) dump, I do in fact see the fields. It's just one of my queries which is complaining, so let me go dig it up and go from there.
Just a follow up :-)
I can query User.SmallPhotoUrl and it works.
Here is the query I am having trouble with..
SELECT CreatedBy.SmallPhotoUrl, CreatedDate, FeedPost.Body, Id, CreatedBy.Name, CreatedById FROM AccountFeed WHERE (ParentId = '0015000000TIHa4AAH') ORDER BY CreatedDate ASC LIMIT 50
I get this error:
SoapFault - faultcode: 'sf:INVALID_FIELD' faultstring: 'INVALID_FIELD:
SELECT CreatedBy.SmallPhotoUrl, CreatedDate
^
ERROR at Row:1:Column:8
No such column 'SmallPhotoUrl' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.'
I guess my problem is a misunderstanding of relationships. From reading the docs I was under the impression that one could pull in any field via the relationship; i.e. CreatedBy.SmallPhotoUrl, CreatedBy.CompanyName etc. I now see that this is not the case.
On an AccountFeed object, I am not understanding why CreatedBy.LastName works but CreatedBy.CompanyName does not.
I need to pull in the CreatedBy.SmallPhotoUrl along with my feed query, otherwise it will be expensive to deref a User object by Id to find the photo url.
I have seen the different urls for ProfilePhoto in Chatter Daily Digest. It is an HTML email displaying profile images of the user. Does any body know how these urls are getting generated? The images display properly without asking you to be login which means there must be some way to generate the publicly available user profile image.
I also want to learn how to acces the profile photo. The old version worked fine even though you didnt get the last version of the photo.
If i just copy n paste the url for the picture it returns: https://flir.my.salesforce.com/profilephoto/7292000000004Kj/F
That link does not work. What to do???
The link should work if you're logged in.
Ahh... it does BUT the id string is no longer the user id. Im guessing it's the image object id.
I was hoping to accomplish something like below on a VF page.
<img align="left" src="https://xxx.my.salesforce.com/profilephoto/{!Opportunity.OwnerId}/F" style="border:1px solid #ccc;"/>
Any instructions on how to accomplish above.
THanks
PS im using the opportunity standard controller and was hoping that no extra coding was needed DS
<
I think this should work.
<img align="left" src="{!Opportunity.Owner.FullPhotoUrl}" style="border:1px solid #ccc;"/>
It would be perfect if that actually worked using the standard opportunity controller.
What do you have to do to get that to work? Using the standard controller i get an error message.
What error message do you get ?
Im getting "Save error: Invalid field FullPhotoUrl for SObject User" when i try to save my visual page to Sales Force.com using Eclipse.
This is the code i use on my visual force page. Before api 20 it was possible to show the picture this way.
Make sure your page is set to be api version 20.
It's because the CreatedBy relationship is for the Name object and not User.
Ergo
This error is coming because "AccountFeed-> CreatedBy" can be either of reference type User or SelfServiceUser. In such cases a polymorphic object is returned on query. This polymorphic object is called "Name" and its having very limited fields as described here
Keep in mind though that the documentation is out of date. The Name sobject has more fields than shown. The Profile sobject has over 60 fields, and the documentation only shows 4.
Thanks SimonF !
After updating Eclipse to api ver 20 and changing the xml file to version 20 it worked like a charm... thank you very much.
Im now using this syntax to display the photo:
<
apex:page standardController="Opportunity" sidebar="true" showHeader="true" >...
<img align="left" src="{!Opportunity.Owner.FullPhotoUrl}" style="border:1px solid #ccc;"/>
Okay I got it working today.
Prior to 2/11/11 you set a sid cookie for .salesforce.com domain. Used the smallPhotoUrl as a relative Url to your API Url.
Post 2/11/11 you set a sid cookie for c.%s.content.force.com domain, where %s is your instance which you can parse from your server Url. Remove the "-api" from it; i.e. na3-api, you use na3 as in c.na3.content.force.com for the cookie domain.
Then you must allow circular redirects in your client because it goes off and authenticates and then comes back to the same photo Url. Set the max redirect to 3.
For example, using HttpClient..
HttpParams params = new BasicHttpParams();
DefaultHttpClient httpclient = new DefaultHttpClient(manager, params);
I should also mention this..
http://stackoverflow.com/questions/2172752/httpsurlconnection-and-intermittent-connections
In using Android I was having very slow image retrieval using HttpClient on some devices. I began using getThreadSafeHttpClient() from that post and it brought the performance back. I'm not sure which param was causing the issue but without it I was seeing an SSL reset upon every image retrieval.
I just found a bug in my code whereby I was submitting a bogus sid on the first request. It turns out that a valid sid in the .salesforce.com domain is fine with the new photo url requests. No circular redirect or .force.com cookie necessary.
That is interesting, in that there doesn't appear to be the need for a sessionid. I can't make rhyme out of the ncsphoto url either. I did notice one thing yesterday when I was implementing the identity url.
Check https://na3.salesforce.com/help/doc/en/remoteaccess_using_openid.htm
You see that there is a "photos" section there with the full and thumbnail of the user. I don't have a response handy, but I don't believe it was the ncsphoto url.
I do have something else critical to add regarding sessionid. This goes along with my post from yesterday:
http://boards.developerforce.com/t5/Security/OAuth-2-0-User-Agent-Flow-token-and-SFDC-UI/td-p/248131
An OAuth2 access_token (used as sessionid) cannot be used to authenticate photo url requests, which hinders the ability of a third-party Chatter application to use OAuth.
cfaherty, did you find out how this relationship with the user table worked?
SELECT CreatedBy.SmallPhotoUrl, CreatedDate, FeedPost.Body, Id, CreatedBy.Name, CreatedById FROM AccountFeed WHERE (ParentId = '0015000000TIHa4AAH') ORDER BY CreatedDate ASC LIMIT 50
I haven't found a way to get the SmallPhotoUrl from people on the feed, only the user logged in. I've tried:
NewsFeed.User.SmallPhotoUrl
FeedItemNewsFeed.User.SmallPhotoUrl
FeedItem.User.SmallPhotoUrl
CreatedBy.User.SmallPhotoUrl
and some others with no luck.
Yes, like this..
SELECT CreatedBy.Profile.CreatedBy.SmallPhotoUrl, CreatedDate, FeedPost.Body, Id, CreatedBy.Name, CreatedById FROM AccountFeed WHERE (ParentId = '0015000000TIHa4AAH') ORDER BY CreatedDate ASC LIMIT
Thanks for the reply cfaherty. The problem is that returns the Photo of the person who created the user's profile, not the person that created the post. Here's my full query.
SELECT CreatedBy.Profile.CreatedBy.SmallPhotoUrl, CreatedBy.Profile.CreatedBy.LastName, Id, Type,
CreatedById, CreatedBy.FirstName, CreatedBy.LastName, CreatedDate,
ParentId, Parent.Name,
Body, Title, LinkUrl,
(SELECT Id, FieldName, OldValue, NewValue
FROM FeedTrackedChanges ORDER BY Id DESC),
(SELECT Id, CommentBody, CreatedDate,
CreatedById, CreatedBy.FirstName, CreatedBy.LastName
FROM FeedComments ORDER BY CreatedDate DESC, ID DESC LIMIT 10),
(SELECT CreatedBy.FirstName, CreatedBy.LastName FROM FeedLikes)
FROM NewsFeed WHERE ParentId = :ApexPages.currentPage().getParameters().get('id')
ORDER BY CreatedDate DESC, ID DESC
LIMIT 10
I guess we both need a solution then. Bummer.
The NewsFeed.CreatedBy is a reference to a Name object, which is often used as a placeholder for polymorphic fields if I remember correctly. I think you'd have to see if there is some other relationship within Name which can be followed.
Why'd they make this so hard?
THANK YOU SO MUCH, SO SO MUCH
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_output_photo.htm