1

Is anyone able to point in the direction of a tutorial on how I go about adding the API to a page. I am guessing I have to create an Apex Class then add code to my page. But I am unsure how I go about doing that....

All I want to do is show a limited number of post (say the top 10 newest) for that particular person who belongs to a specific group.

Any help would be appreciated.

Cheers,

Chris

1 Answer 1

2

you can use Connect in Apex feature for your requirement.To help you start with below article is a great resource

https://developer.salesforce.com/blogs/developer-relations/2013/02/getting-started-with-connect-in-apex.html

Lets replicate some code for reference in case our links break in future

global List<FeedItemInfo> getFeedItems() {
ConnectApi.FeedItemPage feedPage = getFeed();

List<FeedItemInfo> result = new List<FeedItemInfo>();
for (ConnectApi.FeedItem item : feedPage.items) {
    result.add(new FeedItemInfo(item));
}

  return result;
}

Visualforce code

 <apex:page>
 <apex:repeat value="{!feedItems}" var="feedItemInfo">
 <div class="feedItemOuterDiv">
    <div class="feedItemInnerDiv">
        <div class="feedPhotoDiv">
            <apex:image class="imageMargin" width="25" url="{!feedItemInfo.feedItem.photoUrl}"/>
        </div>
        <div class="feedItemBodyDiv">
            <b>{!feedItemInfo.userName}</b><br/>
            <apex:outputText value="{!feedItemInfo.formattedText}" escape="false"/>
        </div>
        <apex:outputPanel rendered="{!IF(feedItemInfo.imageUrl == null, false, true)}" >
            <div class="feedImageDiv" >
                <apex:image class="imageMargin" width="100" url="{!feedItemInfo.imageUrl}"/>
            </div>
        </apex:outputPanel>
     </div>

     <apex:outputPanel rendered="{!IF(feedItemInfo.comments.size > 0, true, false)}">
         <div class="feedCommentOuterDiv">
             <apex:repeat value="{!feedItemInfo.comments}" var="commentInfo">
             <div class="feedCommentInnerDiv">
                 <div class="feedPhotoDiv">
                     <apex:image class="imageMargin" width="25" url="{!commentInfo.comment.user.photo.smallPhotoUrl}"/>
                 </div>
                 <div class="FeedCommentBodyDiv">
                     <b>{!commentInfo.userName}</b><br/>
                     <apex:outputText value="{!commentInfo.formattedText}" escape="false"/>
                 </div>
                 <apex:outputPanel rendered="{!IF(commentInfo.imageUrl == null, false, true)}" >
                     <div class="feedImageDiv" >
                         <apex:image class="imageMargin" width="100" url="{!commentInfo.imageUrl}"/>
                     </div>
                     <div style="clear: both;"/>
                 </apex:outputPanel>
             </div>
             </apex:repeat>
            </div>
           </apex:outputPanel>
         </div>
      </apex:repeat>
    </apex:page>
2
  • Unfortunately, not having much luck with that example provided from the article. The first issue is "FeedItemInfo" is being flagged as Invalid Type when creating my apex class. Do you know what the issue is here? Commented Feb 25, 2015 at 4:16
  • reduce your class version to 28 or so.If you want to figure real issue then go through connect api document and find the correct datatypes .Many things ahve change in connect api. Commented Feb 25, 2015 at 5:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .