I need to use Apex to create a chatter post on an Account object, which will include some text which is a clickable hyperlink. After hours of confusing searches, I thought I had found the solution here, which looks like it does what I need using LinkAttachmentInput but when I tried it out I discovered:
ConnectApi.LinkAttachmentInput
This class isn’t available in version 32.0 and later. In version 32.0 and later, use the ConnectApi.LinkCapabilityInput class.
Unfortunately, after more hours of searching online, I can't find any examples of how to use this new "capabilities" scheme. Has anyone managed to figure out how to use it to embed a link in a post to be created by calling ConnectApi.ChatterFeeds.postFeedElement() ?
Best Answer
Here's some sample code, which I adapted from an example for posting files: