以下是我用来发布给yammer组的代码。
var testMessage = {
body: "hello",
group_id: 123456
}
var jsonObj = JSON.stringify(testMessage);
accToken = responseObject.access_token.token;
var accAuthHead = 'Bearer ' + accToken;
$.ajax({
url: "https://api.yammer.com/api/v1/messages.json",
type: 'POST',
headers: {
'Authorization': accAuthHead.toString(),
},
data: testMessage,
success: function (data) {
alert("ajax post success.");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("There was an error with the request." + textStatus + XMLHttpRequest.toString());
}
});
“错误:拒绝访问”在错误函数中抛出。如果我在这里做错了,请纠正我。