Created
July 7, 2012 04:49
-
-
Save aaronroe/3064754 to your computer and use it in GitHub Desktop.
Doing a post on Yammer via Javascript API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.