-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
58 lines (48 loc) · 1.4 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Codio.io
* Created with yam_jssdk_101.
* User: iogbole
* Date: 2014-10-20
* Time: 09:08 PM
* To change this template use Tools | Templates.
*/
function postMessage() {
yam.getLoginStatus( function(response) {
if (response.authResponse) {
//call the Post function
yamPostRequest(this);
} else {
alert("not logged in")
yam.login( function (response) {
if (!response.authResponse) {
//call the Post function
yamPostRequest(this);
}
});
}
});
}
function yamPostRequest(val) {
var msg_value = document.getElementById('msg_body').value;
var groupID = document.getElementById('group_id').value;
if(msg_value ==""){
alert ("Message body cannot be empty!");
return false;
}
if(groupID==""){
var conf = confirm("Group ID is empty, message will be posted to all company")
if(conf==false) { return false}
}
yam.platform.request(
{
url: "https://api.yammer.com/api/v1/messages.json"
, method: "POST"
, data: {
"body" : msg_value
,"group_id" : groupID
}
, success: function (msg) { alert("Post was Successful!"); }
, error: function (msg) { alert("Post was Unsuccessful"); }
}
)
}