Saturday, January 24, 2015

In the journey of Yammer REST APIs we have seen various APIs and their usages. In this post we will see how to like a post. Like in social applications are very important. Though it looks very small it has most impact power. Like makes any post, message, person famous. Its a index which tells how many people agree with you. And without Like any social application is incomplete so is Yammer and its integrated applications.

So let see how to add a like button in our yammer feeds component in SharePoint. Following is the REST url to like the post:

URL: messages/liked_by/current.json?message_id=[MessageId]

Parameter: This REST service needs message id as input to which you want to like.

You need to pass the id of message as a parameter to the REST call. Following is the sample code to like the message. I'd of message is hardcoded which can be set dynamically in actual implementations.

Sample Code:

<script type="text/javascript" data-app-id="[AppId]" src=""></script>
<script type="text/javascript">
function (response) {
if (response.authResponse) {
else {
yam.platform.login(function (response) {
if (!response.authResponse) {
function Like() { 
 { url: "messages/liked_by/current.json?message_id=[message_id]"
 , method: "POST"
 , success: function (msg) { 
 alert("{Liked it successfully!} "); 
 , error: function (msg) { 
 alert("Post was Unsuccessful..." + msg); 
        <b>Like to Message.</b>
    <button onclick='Like()'>Like!</button>

In this way you can implement Liking using Yammer REST services.

Happy Yamming!


Post a Comment