使用Yammer JS SDK時,您需要引用api.yammer.com而不是www.yammer.com/api/v1。或者更好的是,如果你想清理url,你可以省略protocol,domain和extras(/ api/v1),並且包括REST資源(在你的情況下是建議)和輸出格式(json) 。看下面的例子:
yam.getLoginStatus(
function(response) {
if (response.authResponse) {
console.log("logged in");
yam.platform.request({
url: "suggestions.json", //this is one of many REST endpoints that are available
method: "GET",
data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site
"letter": "a",
"page": "2",
},
success: function (user) { //print message response information to the console
alert("The request was successful.");
console.dir(user);
},
error: function (user) {
alert("There was an error with the request.");
}
});
}
else {
alert("not logged in")
}
}
);