• Amit Singh 2055
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I need to show chatter feed on custom visualforce page simmilar to standard chatter feed.

Below is the chatter feed which i  am trying to show on my vf page.

User-added image
public ConnectApi.FeedElementPage getfeedItemPage() {
        ConnectApi.FeedElementPage feedItemPage ;
        if(entityId != null && entityId != ''){
            feedItemPage= ConnectApi.ChatterFeeds.getFeedElementsFromFeed(Network.getNetworkId(), ConnectApi.FeedType.UserProfile, entityId)  ;
        for(ConnectApi.FeedElement fe : feedItemPage.elements){
                system.debug('+++fes.parent++++'+fe.parent); 
                 }
        }
       
         return feedItemPage;
        
    }
Visualforce code 
<div class="row">
        <div class="col-md-6">
            <apex:repeat value="{!feedItemPage.elements}" var="feedItem">
                              
                <div class="media">
                    <a class="pull-left" href="{!$Page.userProfile}?uid={!feedItem.parent['id']}" target="_blank">
                       
                        <!-- <img class="media-object" src="User Image" />-->
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">
                            <apex:repeat value="{!feedItem.header.messageSegments}" var="segment">
                              
                                <apex:outputPanel rendered="{!(segment.type == EntityLinkSegmentType)}">
                                    
                                    <a href="{!$Page.UserProfile}?uid={!segment['reference'].id}" target="_blank">
                                        <img src="{!segment['motif'].smallIconUrl}"/>
                                        {!segment.text}
                                    </a>
                                </apex:outputPanel>
                                <apex:outputPanel rendered="{!(segment.type == TextSegmentType)}">
                                    {!segment.text}
                                </apex:outputPanel>
                                <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                    <a href="{!$Page.UserProfile}?uid={!segment['record'].id}" target="_blank">@{!segment['record'].name}</a>
                            </apex:outputPanel>
                            </apex:repeat>    
                         </h4>
                                
                        <apex:repeat value="{!feedItem.body.messageSegments}" var="segment">
                            <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                {!segment.text}
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                <a href="{!$Page.UserProfile}?uid={!segment['record'].id}" target="_blank">@{!segment['record'].name}</a>
                            </apex:outputPanel>
                        </apex:repeat>
                        <apex:repeat value="{!feedItem.capabilities.comments.page.items}" var="comment">
                          
                            <div class="media">
                                <a class="pull-left" href="{!$Page.userProfile}?uid={!comment.parent.id}" target="_blank">
                                    <img class="media-object" src="{!comment.user.photo.smallPhotoUrl}" alt="{!comment.user.firstname}"/>
                                </a>
                                <div class="media-body">
                                    <h4 class="media-heading">
                                        <a href="{!$Page.userProfile}?uId={!comment.user.id}" target="_blank">
                                            {!comment.user.firstname} {!comment.user.lastname}
                                        </a>  
                                    </h4>
                                    <apex:repeat value="{!comment.body.messageSegments}" var="segment">
                                        <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                            {!segment.text}
                                        </apex:outputPanel>
                                        <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                            <a href="{!$Page.UserProfile}?uId={!segment['record'].id}">@{!segment['record'].name}</a>
                                        </apex:outputPanel>
                                    </apex:repeat>
                                </div>
                            </div>
                        </apex:repeat>
                    </div>
                </div>
            </apex:repeat>
        </div>
Issue -- I am not able to get the user Id and picture.(Marked by red arrow in pic)

Though when i am running my page and checking the debug log i am able to show the user details in debug log-
+++fes.parent++++ConnectApi.UserSummary[buildVersion=33.0, additionalLabel=null, communityNickname=amitcoh1.4333333638497007E12, companyName=SPN, displayName=Amit Singh, firstName=Amit, id=00528000000Jw2NAAS, isActive=true, isInThisCommunity=true, lastName=Singh, motif=ConnectApi.Motif[buildVersion=33.0, color=34BECD, largeIconUrl=/img/icon/profile64.png, mediumIconUrl=/img/icon/profile32.png, smallIconUrl=/img/icon/profile16.png], mySubscription=null, name=Amit Singh, photo=ConnectApi.Photo[buildVersion=33.0, fullEmailPhotoUrl=https://ap2.salesforce.com/ncsphoto/DZ3K8U2-znZz0Tg2cW1h__QotriCshvQ5vGSl0YwjMOySlRLBv53qpnE7UwU_9Ay, largePhotoUrl=https://c.ap2.content.force.com/profilephoto/729280000000DC7/F, photoVersionId=729280000000DC7AAM, smallPhotoUrl=https://c.ap2.content.force.com/profilephoto/729280000000DC7/T, standardEmailPhotoUrl=https://ap2.salesforce.com/ncsphoto/DZ3K8U2-znZz0Tg2cW1h__QotriCshvQ5vGSl0YwjMMDhDDbaFZVpVomaJ0EHoSF, url=/services/data/v33.0/chatter/users/00528000000Jw2NAAS/photo], reputation=null, title=null, type=User, url=/services/data/v33.0/chatter/users/00528000000Jw2NAAS, userType=Internal]
In API Version 31.0 We use ConnectAPI.actor class to get user details.But after API V 32.0 this class is not available.
I Found some link also how can we show the chatter feed on vf page but those are based on API v 31.
http://appirio.com/category/tech-blog/2014/01/chatter-apex/

Can anyone help me to get the user detail from ConnectAPI.feedElement  in API 34.0 ?

Thanks
Amit Singh