Skip to content

Instantly share code, notes, and snippets.

@aaronroe
Created July 7, 2012 04:49
Show Gist options
  • Save aaronroe/3064754 to your computer and use it in GitHub Desktop.
Save aaronroe/3064754 to your computer and use it in GitHub Desktop.
Doing a post on Yammer via Javascript API
<html>
<head>
<title>A Yammer App</title>
<script src="https://assets.yammer.com/platform/yam.js"></script>
<script>
yam.config({appId: "APP-ID"});
</script>
</head>
<body>
<button onclick='post()'>Post on Yammer!</button>
<script>
function post() {
yam.getLoginStatus( function(response) {
if (response.authResponse) {
yam.request(
{ url: "https://www.yammer.com/api/v1/messages.json"
, method: "POST"
, data: { "body" : "This Post was Made Using the Yammer API. Welcome to the Yammer API World."}
, success: function (msg) { alert("{Post was Successful!}: " + msg); }
, error: function (msg) { alert("Post was Unsuccessful..." + msg); }
}
)
} else {
yam.login( function (response) {
if (!response.authResponse) {
yam.request(
{ url: "https://www.yammer.com/api/v1/messages.json"
, method: "POST"
, data: { "body" : "This Post was Made Using the Yammer API. Welcome to the Yammer API World."}
, success: function (msg) { alert("{Post was Successful!}: " + msg); }
, error: function (msg) { alert("Post was Unsuccessful..." + msg); }
}
);
}
});
}
});
}
</script>
</body>
</html>
@Krish262018
Copy link

Krish262018 commented Jun 26, 2018

Dear how to use the above code in office 365 to post the list item title to our yammer post.
I tried above but not getting posted.
when some one post through API,still its showing as posted by my Name.Also one static message is coming as"Posted through yammer Developer SDK".how to avoid this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment