Monday, December 29, 2014


We learned about basics of search responses and refiners. Now we will see how to implement a basic search component with the help of Search REST services. This is simple to implement all you need to know is how to construct REST URL and how to use their response.

The REST URL for Search is : /_api/search/query?querytext=’text’

Following is the complete code which searches on the text provided in the textbox and shows on the screen.

HTML Code:

<script type="text/javascript" src="/Site%20Assets/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/Site%20Assets/js/knockout.3.2.0.js"></script>
<script type="text/javascript" src="/Site%20Assets/js/SimpleSearch.js"></script>

<div class="row">
<div class="col-xs-12 col-sm-8 col-md-8">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<input type="text" class="form-control" placeholder="Search" id="txtSearch">
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<button type="button" class="btn btn-default" data-bind="click: btnSearchClick">Search</button>
</div>
</div>
<div class="row">
<div style="width:100%;padding-left:10px;" data-bind="foreach: SearchResults">
<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-12" style="border-bottom: 1px solid;padding-bottom:10px;">
<div style="width:100%">
<a href="" data-bind="attr: { href: Url }"><h4><span data-bind="text: Title"> </span></h4></a>
</div>
<div style="width:100%">
<p data-bind="html: HitHighlightedSummary"> </p>
</div>
<div style="width:100%">
<a href="" data-bind="attr: { href: Path }"><span data-bind="text: Path"> </span></a>
</div>
<div style="width:100%">
<span class="label label-default"> Author: <span data-bind="text: Author"> </span> </span>
</div>
  </div>
</div>
</div>
</div>
</div>
</div>

JS code:

var RESTURL = "/_api/search/query?querytext=";
$(document).ready(function () {
    KOViewModel();
});
function KOViewModel()
{
 var self = this;
 self.SearchResults = ko.observableArray([]);
 self.SearchResult = function(url,title,hitHighlightedSummary,author,path)
 {
 var self = this; 
 self.Url = url;
 self.Title = title;
 self.HitHighlightedSummary = hitHighlightedSummary;
 self.Author = author;
 self.Path = path;
 }
 self.btnSearchClick = function()
 {
self.Search();
 }
 self.Search = function()
 {
 var searchtext = $("#txtSearch").val();
 self.SearchResults.removeAll();
 $.ajax({
url: RESTURL + "'" + searchtext + "'",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
$.each(data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results, function () {
 self.SearchResults.push(new self.SearchResult(this.Cells.results[6].Value,this.Cells.results[3].Value,this.Cells.results[11].Value,this.Cells.results[4].Value,this.Cells.results[6].Value));
 
});
},
error: function (error) {  
alert(JSON.stringify(error));
}
 });
}
ko.applyBindings(self);
}


Note: Knock out framework has been used in above component. To run this code you need to refer knock out js file.

Happy SharePoint coding.

Saturday, December 27, 2014


Search in SharePoint is most important and mostly used feature. Creating custom search controls through c# is complex  and requires farm level deployment. In the world of REST services farm solution is not correct approach. SharePoint 2013 has  REST services which enables you to work with SharePoint search. And these services are true friends of developers like me who scares of Search. In coming posts we will learn how to use Search REST services and its options.

REST URL to make search on text is:
/_api/search/query?querytext='text' 

If you open this REST URL in browser you will get the results like below. The response is huge and little bit complicated but if you read it carefully then you will understand all objects returned in response. So in this post we will learn how to read the response returned by Search REST service.

Let’s see the each section closely:

1. PrimaryQueryResult

This is first child element of ‘dada.d.Query’ , another one is ‘Properties’ will see it later. PrimaryQueryResult is the main element of search REST response. It contains following important elements: RefinementResults, ReleventResults and other elements are QueryId, QueryRuleId. Following screenshot shows the element.



2. RelevantResults

This is child element of ‘PrimaryQueryResult’ and it contains the search results. It contains search result in the form of array. To iterate through the results array you need to get like: data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results. Following code snippet iterate through it:

$.each(data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results, function () {
 }); 

RelevantResults also contains following elements: Properties, RowCount, TotalRows, TotalRowsIncludingDuplicates.
RowCount – This is count search results returned in response.
TotalRows – this represents number of matches found for the search text.
TotalRowsIncludingDuplicates - this represents number of matches found for the search text including duplicates.



3. RefinementResults

This element contains the list of refiners found for the search text. You can get them in the ‘Refiners’ element.
To get the refiners you need to construct the REST url like below:
/_api/search/query?querytext='yammer'&refiners='Write,DisplayAuthor,ContentType,FileExtension,FileType'.  



4. Refiners 

This tag contains the list of refiners returned in the result with their refiner tokens as shown in below screenshot. We will see more in it in next post.



So this is how the search result gets constructed. I have explained above only those elements which are important while development. In next post we will see how to get search results and bind them on screen.

Happy SharePoint Coding.

Friday, December 26, 2014


In previous post I explained how to fetch the followers and this article we will see how to get those to whom the mentioned person is following. This is also a important part in social networking; this is nothing but half of social network on social site. Following and followed_by helps to com the person quickly in the network. It also helps to receive the updates from those users. Now lets see how to develop a component for SharePoint community which shows users to which current user is following.

Following is the REST API URL: "users/following/[userid].json"

Complete code snippet:

<script type="text/javascript" data-app-id="[data-app-id]" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script> 
<script type="text/javascript">
var userId = "[userId]";
var htmlstr = "<div><a href='[URL]'>[NAME]</a></div>";
yam.getLoginStatus(
function (response) {
if (response.authResponse) {
GetFollowing();
}
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
GetFollowing();
}
});
}
});

function GetFollowing(){
yam.platform.request(
 {
 url: "users/following/" + userId +".json"
 , method: "GET"
 , success: function (responseData) {
 ShowHtml(responseData,false);
 }
 , error: function (msg) { 
 alert("Error..." + msg); 
 }
 }
)
}
function ShowHtml(responseData,isNext)
{
var htmlTobind = "";
var last;
for (var j = 0; j < responseData.users.length; j++) {
var html = htmlstr.replace("[NAME]",responseData.users[j].full_name);
html = html.replace("[URL]",responseData.users[j].web_url);

htmlTobind = htmlTobind + html;
}
$("#msgsection").html(htmlTobind);
}
</script>  
<div class="container-fluid" style="margin-top:15px;height:600px;overflow-y:scroll;">
<div id="msgsection" style="width:100%;">
</div>
</div>

Happy  Yamming and SharePoint coding

In the journey of Learning Yammer we have touched various corners of Yammer technology. Yammer is a social network where you can do all  your social activities. You can integrate Yammer with your SharePoint 2013 sites to create community. You can do various things with various options available in Yammer. In this article we will see how to get list of users who are following me on Yammer network. Following and Followers are very important groups in social network. These two groups makes your network on social site. So without these two components your community site is incomplete.

In this article we will see how to get followers of a user. We will achieve this using Yammer REST APIs. Below REST URL returns the followers of a user.

URL: "users/followed_by /[userid].json"

This URL is not mentioned in the Yammer documentation but this gives the expected results. It returns all the users details which are following the mentioned user.
Following script fetches all followers and shows on the screen.

Complete Script:

<script type="text/javascript" data-app-id="[data-app-id]" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script> 
<script type="text/javascript">
var userId = "userid";
var htmlstr = "<div><a href='[URL]'>[NAME]</a></div>";
yam.getLoginStatus(
function (response) {
if (response.authResponse) {
GetFollowing();
}
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
GetFollowing();
}
});
}
});
function GetFollowing(){
yam.platform.request(
 {
 url: "users/followed_by/" + userId +".json"
 , method: "GET"
 , success: function (responseData) {
 ShowHtml(responseData,false);
 }
 , error: function (msg) { 
 alert("Error..." + msg); 
 }
 }
)
}
function ShowHtml(responseData,isNext)
{
var htmlTobind = "";
var last;
for (var j = 0; j < responseData.users.length; j++) {
var html = htmlstr.replace("[NAME]",responseData.users[j].full_name);
html = html.replace("[URL]",responseData.users[j].web_url);

htmlTobind = htmlTobind + html;
}
$("#msgsection").html(htmlTobind);
}
</script>  
<div class="container-fluid" style="margin-top:15px;height:600px;overflow-y:scroll;">
<div id="msgsection" style="width:100%;">
</div>
</div>

You need to provide data app id and user id in above script to run it.

Happy Yamming and SharePoint coding.

Sunday, December 21, 2014


We will continue our exploration in Yammer world to learn new things. Till now  we have seen how to get messages for logged in user, how to post message in Yammer. In this article we will specifically see how to fetch messages of a specific group.

We have seen in my previous posts where you can use Yammer web part and embed code to show messages of a particular group. But the problem with them is they are not mobile device complaint; they are not RWD complaint. So what if you are planning to have your SharePoint site mobile devices complaint or RWD complaint? How can you show the group messages on those devices?

The option you left with is Yammer REST APIs. But if you check the Yammer API documentation site then you will not find any REST service to get the group messages. With many combination and try I got following REST URL can help you to get the messages. This Url is not mentioned in Yammer documentation but it is working; hopefully we will get better documentation in future.

URL: 'messages/in_group/[Group ID].json'

You need to provide your intended group id in above URL.

Following is code snippet which shows how to fetch messages of a specific group.
Code Snippet:

<script type="text/javascript" data-app-id="[data-app-id]" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script> 
<script type="text/javascript">
var resultslimit = 20;
var htmltemplatestr = "<div ><div ><a href='[USERURL]' target='_blank'><img src='[IMG]' /><br/>[SENDER]</a></div><div ><div ><p>[TEXT]<br/>[DATE]</p></div></div></div>";
yam.getLoginStatus(
function (response) {
if (response.authResponse) {
GetMsg();
}
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
GetMsg();
}
});
}
});
function GetMsg(){
var groupID = "4409501";
yam.platform.request(
 {
 url: "messages/in_group/" + groupID + ".json"
 , method: "GET"
 , data: { 'limit': resultslimit}
 , success: function (responseData) {
 ShowHtml(responseData,false);
 }
 , error: function (msg) { 
 alert("Error..." + msg); 
 }
 }
)
}
function ShowHtml(responseData,isNext)
{
var htmlTobind = "";
var last;
for (var j = 0; j < responseData.messages.length; j++) {
var sender = $.grep(responseData.references, function(e){ return e.id == responseData.messages[j].sender_id; });
var html = htmltemplatestr .replace("[DATE]",DateStr(responseData.messages[j].created_at));
//this returns the all parents messages in groups
if(responseData.messages[j].replied_to_id == null)
{
html = html.replace("[TEXT]",responseData.messages[j].body.rich);
}
html = html.replace("[IMG]",sender[0].mugshot_url); 
html = html.replace("[USERURL]",sender[0].web_url);
html = html.replace("[SENDER]",sender[0].full_name);
htmlTobind = htmlTobind + html;
last = responseData.messages[j].id;
}
$("#msgsection").html(htmlTobind);
}
function DateStr(dateStr) {
    var monthNames = new Array("January", "February", "March",
        "April", "May", "June", "July", "August", "September",
        "October", "November", "December");
    var dt = new Date(dateStr);
    var curr_date = dt.getDate();
    var curr_month = dt.getMonth();
    var curr_year = dt.getFullYear();
    return monthNames[curr_month] + " " + curr_date + " at " + dt.getHours() + ":" + dt.getMinutes();
</script>  

<div style="margin-top:20px;height:800px;overflow-y:scroll;">
<div id="msgsection" style="width:100%;">
</div>
</div>



Happy Yamming and SharePoint coding.

We have seen how to post messages using REST services in group and sending private messages to other user. In this article we will see how to reply a message.

This is very common operation which is required for any yammer feed components. If you use Yammer web part or App you got options to reply to messages. But in case of REST implementation you need to implement replying functionality so user can reply to messages.

You can use REST service which is used to post the messages to yammer. In case of reply you need to provide a message id to which you want to reply. Following is the REST URL and its required parameters. 

URL: “messages.json”

Required Parameters: 'replied_to_id'

Code Snippet:

    <script type="text/javascript" data-app-id="[data-app-id]" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
<script type="text/javascript">
yam.getLoginStatus(
function (response) {
if (response.authResponse) {
}
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
}
});
}
});
function Reply() {                             
var messageToPost = document.getElementById("txtMessage").value; 
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { body: messageToPost, replied_to_id: "478732307" }
 , success: function (msg) { 
 alert("{Replied Successfully!}: " + msg); 
 }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
);  
}
</script>
    <div>
        <b>Reply to Message.</b>
    </div>
    <div style="width:500px;">
        <textarea id="txtMessage" style="height:100px;width:100%;"></textarea>
    </div>
    <div>&nbsp;</div>
    <div>
    <button onclick='Reply()'>Reply!</button>
    </div>

In this way you can implement replying functionality. To use above code use your data-app-id.

Happy Yamming.

In last post we saw how to post message to yammer using REST and its various options. In this article we will see how to broadcast message using same REST API.

This is common requirement where management personals or super administrator wants to send out important messages to everyone.

Following are the general scenarios where you can use this component:
1. Sending awareness messages to all.
2. Sending viruses awareness to all to avoid any disaster.
3. Sending change in policy and procedures to everyone.
4. Sending out software update information to everyone.
5. Making any important Announcements.

Such various official activities can be done by this component.

Following is the REST URL for posting the message as broadcast, this is same URL which we saw in last article. Only difference is you need to provide a parameter: 'broadcast=true ' to the REST API. To broadcast the message you must be verified admin otherwise it will fail.

URL: "messages.json"

Parameter: ‘broadcast’ and value ‘true’.

Required Role: Verified administrator

Following is the complete code snippet for broadcasting message.

<script type="text/javascript" data-app-id="[data-app-id]" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
<script type="text/javascript">

yam.getLoginStatus(
function (response) {
if (response.authResponse) {
}
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
}
});
}
});
function post() {        
var messageToPost = document.getElementById("txtMessage").value; 
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { body: messageToPost, broadcast:true }
 , success: function (msg) { 
 alert("{Post was Successful!}: " + msg); 
 }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
);  
}
</script>
    <div>
        <b>Broadcast.</b>
    </div>
    <div style="width:500px;">
        <textarea id="txtMessage" style="height:100px;width:100%;"></textarea>
    </div>
    <div>&nbsp;</div>
    <div>
    <button onclick='post()'>Send to All!</button>
    </div>

In above code replace [data-app-id] with your actual data-app-id while trying out this code.

Happy  Yamming.

Monday, December 15, 2014


In last article we saw how to broadcast a messages using REST API. But sometimes it is required that you need to send a message to a person in private so others cannot see it. It could be one to one feedback, any personal update. Or something confidential information.

In this article we will see how to post private message to user using REST service. The REST URL remains same which we used for posting message, the only difference is the parameter. In case of private sending private messages use  parameter 'direct_to_id' of user.

URL: "messages.json"

Required parameters: ‘direct_to_id’

Complete code snippet:

<script type="text/javascript">
function post() {                             
                var messageToPost = document.getElementById("txtMessage").value; 
yam.getLoginStatus( function(response) {
if (response.authResponse) {
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { "body": messageToPost, "direct_to_id": "1518699585" }
 , success: function (msg) {
 alert("{Post was Successful!}: " + msg); 
 }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
)
} else {
yam.platform.login( function (response) {
 if (!response.authResponse) {
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { body: messageToPost, direct_to_id: "1518699585" }
 , success: function (msg) { alert("{Post was Successful!}: " + msg); }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
);
 }
});
}
});
}
</script>
    <div>
        <b>Send Private Message.</b>
    </div>
    <div style="width:500px;">
        <textarea id="txtMessage" style="height:100px;width:100%;"></textarea>
    </div>
    <div>&nbsp;</div>
    <div>
    <button onclick='post()'>Send to Friend!</button>
    </div>


Happy SharePoint coding.

Thursday, December 11, 2014


We have seen how to fetch messages from Yammer for various purposes using Yammer REST API. Now is the time to post messages to Yammer. We will see how to create a component which can be used to post messages to yammer.

REST URL used to post messages is: "messages.json"

Once message gets posted successfully it returns current message in response so user can refresh your component’s screen. You can post only one message at a time using this Yammer REST.

Following is the complete code to post message:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
 <script type="text/javascript" data-app-id="[Data-App-ID]" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
<script type="text/javascript">
function post() {                             
                var messageToPost = document.getElementById("txtMessage").value; 
yam.getLoginStatus( function(response) {
if (response.authResponse) {
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { "body": messageToPost, "group_id": "4409501" }
 , success: function (msg) { alert("{Post was Successful!}: " + msg); }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
)
} else {
yam.platform.login( function (response) {
 if (!response.authResponse) {
yam.platform.request(
 { url: "messages.json"
 , method: "POST"
 , data: { body: messageToPost, group_id: 4409501 }
 , success: function (msg) { alert("{Post was Successful!}: " + msg); }
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
 }
 }
);
 }
});
}
});
}
</script>
    <div>
        <b>Share an Update.</b>
    </div>
    <div style="width:500px;">
        <textarea id="txtMessage" style="height:100px;width:100%;"></textarea>
    </div>
    <div>&nbsp;</div>
    <div>
    <button onclick='post()'>Post on Yammer!</button>
    </div>

In above code you need to provide your Data-App-ID.  In this way you can post message to any Yammer group. Don't forget to provide your group id. 


Happy SharePoint 2013.

Wednesday, December 10, 2014


We have seen how to manipulate the messages using Yammer REST services; how to implement components for SharePoint sites. In this section we will see how to display Yammer notifications to user. Yammer has provided REST service to get the notification for current user.

Following is the REST service to get notification: /api/v1/streams/notifications.json.

This service returns the yammer notification for current logged in user. You can also get the read/unread status of each notifications.  Yet they have not provided any api to mark the notification as read. But nevertheless we can get notifications using this service.

Following complete code shows notification on the screen:

    <div class="container" style="padding:50px;">
<div class="container-fluid">
<div id="notifications" class="list-group">
</div>
</div>
    </div> 
    <script type="text/javascript" data-app-id="[APP-ID]" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
var html = "<a href='[WEB_URL]' class='list-group-item'><h6 class='list-group-item-heading'><div style='float:left'><strong>[ACTOR] &nbsp;&nbsp; [MSGTYPE] in &nbsp;&nbsp;</strong></div><div id='[GROUP]'><strong>[GROUPNAME]</strong></div></h6><p class='list-group-item-text'style='word-wrap: break-word;'><small>[TEXT]</small></p></a>";

function GetNotiFications()
{
yam.getLoginStatus( function(response) {
        if (response.authResponse) {
yam.platform.request(
              { url: "streams/notifications.json"
              , method: "GET"
              , data: {  }
              , success: function (msg) { 
BindResult(msg);
}
              , error: function (msg) { alert("Error..." + msg); }
              })
        } else {
            yam.platform.login( function (response) {
              if (!response.authResponse) {
                yam.platform.request(
                  { url: "streams/notifications.json"
                  , method: "GET"
                  , data: { }
                  , success: function (msg) { BindResult(msg); }
                  , error: function (msg) { alert("Error..." + msg); }
                  }
                );
              }
            });
        }
    });

}

function BindResult(resp)
{
var finalHtml = "";
for(var i=0; i<resp.items.length; i++)
{
if(resp.items[i].category == "group-auto-add")
{
var actorre = new RegExp("\(user:\)[0-9]*");
var actorm = actorre.exec(resp.items[i].message);
var actorid = actorm[0].split(":")[1];
var actor = $.grep(resp.references, function(e){ return e.id == actorid; });
var groupre = new RegExp("\(group:\)[0-9]*");
var groupm = groupre.exec(resp.items[i].message);
var groupid = groupm[0].split(":")[1];
var group = $.grep(resp.references, function(e){ return e.id == groupid; });
var msg = resp.items[i].message.replace("[[" + actorm[0] + "]]",actor[0].full_name);
msg = msg.replace("[[" + groupm[0] + "]]",group[0].full_name);
finalHtml = finalHtml + "<a href='" + group[0].web_url + "' class='list-group-item'><h6 class='list-group-item-heading'>" + msg + "</h6></a>";

}
else if(resp.items[i].category == "mention-or-reply")
{
//alert(resp.items[i].message);
var msg = resp.items[i].message;
while(msg.indexOf("user:") != -1)
{
var actorre = new RegExp("\(user:\)[0-9]*");
var actorm = actorre.exec(msg);
var actorid = actorm[0].split(":")[1];
var actor = $.grep(resp.references, function(e){ return e.id == actorid; });

msg = msg.replace("[[" + actorm[0] + "]]",actor[0].full_name);
}

if(msg.indexOf("group:") != -1)
{
var groupre = new RegExp("\(group:\)[0-9]*");
var groupm = groupre.exec(msg);
var groupid = groupm[0].split(":")[1];
var group = $.grep(resp.references, function(e){ return e.id == groupid; });
msg = msg.replace("[[" + groupm[0] + "]]",group[0].full_name);
}

finalHtml = finalHtml + "<a href='#' class='list-group-item'><h6 class='list-group-item-heading'>" + msg + "</h6></a>";

}
else if(resp.items[i].category == "new-follower")
{
var infoObjects = $.grep(resp.objects.user, function(e){ return e.id == resp.items[i].objects[0].id; });
finalHtml = finalHtml + "<a href='" + infoObjects[0].web_url + "' class='list-group-item'><h6 class='list-group-item-heading'>You have new follower " + infoObjects[0].full_name + "</h6></a>"
}
else
{
var actor =resp.items[i].message.split(":");
actor = actor[1].split("]");

        var infoObjects = $.grep(resp.objects.message, function(e){ return e.id == resp.items[i].objects[0].id; });
        var user = $.grep(resp.references, function(e){ return e.id == actor[0]; });

 if(infoObjects != null)
 {
if(infoObjects[0].web_url != undefined)
{
finalHtml = finalHtml + html.replace("[WEB_URL]", infoObjects[0].web_url);
}
finalHtml = finalHtml.replace("[MSGTYPE]", resp.items[i].category);
if(infoObjects[0].group_id == null)
{
finalHtml = finalHtml.replace("[GROUP]", "All Company");
finalHtml = finalHtml.replace("[GROUPNAME]", "All Company");
}
else
{
finalHtml = finalHtml.replace("[GROUP]", infoObjects[0].group_id);
var group = $.grep(resp.references, function(e){ return e.id == infoObjects[0].group_id; });
finalHtml = finalHtml.replace("[GROUPNAME]", group[0].full_name);
}
if(resp.items[i].category == "announcement-create")
{
finalHtml = finalHtml.replace("[TEXT]", infoObjects[0].title);
}
else
{
finalHtml = finalHtml.replace("[TEXT]", infoObjects[0].content_excerpt);
}
finalHtml = finalHtml.replace("[ACTOR]", user[0].full_name);

finalHtml = finalHtml.replace("likes-message", "likes message");
finalHtml = finalHtml.replace("announcement-create", "creates announcement");
}
}
finalHtml = finalHtml.replace("[CSSCLASS]", "list-group-item list-group-item-info");
}
$("#notifications").html(finalHtml);
$("#pop").popover();
}
GetNotiFications();
</script>

This is complete code which shows notifications from Yammer of current user. You need to provide your app-id in this code. And with the help of content editor place this code on page and enjoy Yammer notification. :)

Happy SharePoint coding.