我尝试使用Open Graph写入Yammer活动源但我收到400错误请求错误。我想知道网址或数据是否错误。
function postToActivity() {
yam.getLoginStatus( function(response) {
if (response.authResponse) {
yam.request(
{ url: "https://api.yammer.com/api/v1/activity.json" //note: the endpoint is api.yammer...
, method: "POST"
, data: {
"activity" : {
"actor" : {
"name" : "Ken Domen",
"email" : "ken.domen@nike.com",
"action" : "like",
"object" : {
"url" : "http://www.google.com",
"title" : "Test"
}
}
}
}
, success: function (msg) {
alert("Post was Successful!: " + msg.messages[0].id); //id of new message
}
, error: function (msg) { alert("Post was Unsuccessful..." + msg); }
}
);
} else {
yam.login( function (response) {
//nothing
});
}
});
}
答案 0 :(得分:1)
嗯,这对我有用:
创建一个Open Graph页面:
yam.platform.request({
url: "https://api.yammer.com/api/v1/activity.json",
method: "POST",
data: {
"activity": {
"actor": { "name": "my name", "email": "my email" },
"action": "create",
"object": { "url": "http://google.is", "title": "the page title"},
"type": "url"
}
},
success: function (res) {
alert("The request was successful.");
console.dir(res);
},
error: function (res) {
alert("There was an error with the request.");
console.log(res)
}
})
将消息发布到打开的图表页面:
yam.platform.request({
url: "https://api.yammer.com/api/v1/messages.json",
method: "POST",
data: {
"body" : "Message body",
"group_id": "grup id, i.e. 12345678",
"og_url": "http://google.is"
},
success: function (res) { //print message response information to the console
alert("The request was successful.");
console.dir(res);
},
error: function (res) {
alert("There was an error with the request.");
console.log(res)
}
})
答案 1 :(得分:0)
我遇到了同样的400错误。就我而言,解决方案非常简单。我用于 group_id 名称,而不是group_id。
您可以让group_id将您的浏览器指向您感兴趣的群组。在网址参数中,您将拥有:?type = in_group&amp; feedId = 3028738 feedId < / strong>是group_id。
我纠正了这个并开始完美地工作。
我不是说这可能是你的情况,但希望它有所帮助。