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

0 comments:

Post a Comment