You need to sign in to do that
Don't have an account?
Sachin_K
Posting image and link in chatter feed through apex code
Hi
I am able to post a link using feeditem object and setting its type as "link post". Besides link, I need to post a image to chatter feed. It should not be like a separate file that got uploaded.
Sample output :
chatter page
username : some content goes here <image> some content goes here
My link
<image> - an external link is used to display the image
Thanks.
You may use a link to point to your image in a Feed,
FeedItem fi = new FeedItem();
fi.Body = ' image link is : www.google.com !!!';
fi.ParentId = '#######'; //UserId or GroupId
insert fi;
Hi Jia,
Thanks for the reply.
But by this method we are getting the link and not the image in the chatter. What we want is to display a image (image link we have in advance) in the chatter. Do you if this is possible?
Thanks,
Sachin
But technically it is possible. On the Chatter page, in the beginning of each feed, system uses different small pictures to distinguish different Feed's parent, such as Contact, Group, Lead,..
If they make this available for our Feed, we can do the same thing.
You can post an image in a chatter feed item using the Chatter REST API. The image can be a new binary included in your request, or you can provide the ID of existing content for your image.
Thanks for your hint.
Now, I can post through Chatter REST API. But I donot know how to include the binary into the text post.
Can you give me an example or a link?
Hi Jia,
Linked from the Chatter API wiki page here: http://wiki.developerforce.com/page/Chatter_API
There are some examples of how to post a binary with your feed item:
- Raw HTTP: https://gist.github.com/2776843
- Ruby: https://github.com/henriquez/multipart-post/blob/master/lib/composite_io.rb
- Java: https://github.com/developerforce/Chatter-REST-API/wiki/Posting-a-file-from-Java
In addition, I have an Objective-C example here: https://github.com/cseymourSF/Chatter-API-iOS-Sample/blob/master/Classes/UserPhotoPoster.m
But all of them are posting image as a attachment to a Feed,...
I guess it is impossible to post a image in the Body of the Feed.
I don't understand what you are looking for. It is impossible to post an image in the feed without it being an attachment to a feed item. There is no way to do that through the regular UI, so there is no API for it either.
But Sachin_K is trying to find a way of posting image in the post body, and it seems you give the hope :)