Skip to content

Instantly share code, notes, and snippets.

@iogbole
Created September 23, 2016 11:01
Show Gist options
  • Save iogbole/adf8cefde124ea64aec20f1ec1d35179 to your computer and use it in GitHub Desktop.
Save iogbole/adf8cefde124ea64aec20f1ec1d35179 to your computer and use it in GitHub Desktop.
Follow Yammer user using the API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>A Yammer App</title>
<script type="text/javascript" data-app-id="lMBUSLNpqydFteLeZPU1GA" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
<script type="text/javascript">
function FollowUser() {
yam.getLoginStatus(function(response) {
if (response.authResponse) {
//call the Post function
yamPostRequest();
} else {
alert("not logged in")
yam.login(function(response) {
if (!response.authResponse) {
//call the Post function
yamPostRequest();
}
});
}
});
}
function yamPostRequest() {
yam.platform.request({
url: "https://api.yammer.com/api/v1/subscriptions.json",
,method: "POST"
//,contentType: "application/json; charset=utf-8"
,data: {
target_id: "1589489029",
target_type: "user"
},
success: function(msg) {
alert("Successful!");
},
error: function(msg) {
alert("Unsuccessful");
}
})
}
</script>
</head>
<body>
<button onclick='FollowUser()'>Follow User</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment