FB.api对组的POST返回GET 500(内部服务器错误)
FB.api POST to a group is returning GET 500 (Internal Server Error)
我知道这一定是一件简单的事情,但就我的一生而言,我无法通过检查我的代码或使用谷歌来获得可能原因的帮助来找到答案!
这是我桌子的照片:
(图片会放在这里,但显然我必须至少有10个声誉才能发布图片?)
图片描述:一个简单的HTML表,有一个Header行和与我所属的Facebook群组一样多的后续行。共有5列:图标、名称、电子邮件、ID,以及用于删除特定行的按钮的一列。
表结构和数据是使用JavaScript函数动态构建的。
以下是我的JavaScript函数,它形成并处理对FB.api的调用:
function postMessage() {
groupsTbl = document.getElementById("groupsTbl");
msgSubject = document.getElementById("msgSubject");
msgBody = document.getElementById("msgBody");
msgPic = document.getElementById("msgPic");
FB.getLoginStatus(
function(response) {
if (response.status === 'connected') {
for (var i = 1; i < groupsTbl.rows.length; i++) {
row = groupsTbl.rows[i].cells;
/* make the API call */
FB.api(
"/" + row[3].innerHTML + "/feed",
"POST",
{ "object": { "message": "this is a test" } },
function (response) {
if (response && !response.error) {
console.log(response);/* handle the result */
}
else
console.log(response);/* handle the result */
}
);
}
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
}
);
}
结果是这样的
正如您从屏幕截图顶部看到的,ID已成功检索并打印到控制台以进行调试。GET的ID似乎是正确的,但显然出了问题!
(图片会放在这里,但显然我必须至少有10个声誉才能发布图片?)
图像描述:
126566634108032 (index):123
GET https://graph.facebook.com/157375201005164/feed?access_token=CAAVK9GATPtMBA…&object=%7B%22message%22%3A%22this%20is%20a%20test%22%7D&pretty=0&sdk=joey 500 (Internal Server Error) debug.js:6245
Object {error: Object}
error: Object
message: "unknown error"
type: "http"
__proto__: Object
__proto__: Object
查看https://developers.facebook.com/docs/javascript/reference/FB.api/#examples有一个Example: Publish a status message to the current user's feed
:
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
转移到你的代码,这将在中产生
FB.api(
"/me/feed",
"POST",
{ message: "this is a test" },
function (response) {
if (response && !response.error) {
console.log(JSON.stringify(response));
}
else
console.log(JSON.stringify(response.error));
}
;
相关文章:
- SignalR:调用集线器方法时出现内部服务器错误
- 如何解决“;错误所请求的URL返回500-内部服务器错误”;
- 使用javascript API响应内部服务器错误将曲目上传到SoundCloud
- AJAX错误状态代码500内部服务器错误
- Jcrop&画布:裁剪区域的大小很奇怪;500内部服务器错误
- 如果JS会话变量为null,如何避免500内部服务器错误
- POST encodeURI查询字符串内部服务器错误 500
- getJSON:网络错误:500 内部服务器错误
- Node.js:Mongoose内部服务器错误
- 缺少用于创建的模板.内部服务器错误-聚合物表单保存到数据库
- Jquery AJAX Post:500(内部服务器错误)
- CSS和Javascript可以在内部服务器上工作,但不能在外部工作
- 我的联系表格在测试/PHPMailer后给了我一个内部服务器错误(500)
- 500(内部服务器错误)的外部php文件
- 内部服务器错误在 post 请求中使用 Angular js 中的自定义服务
- 内部服务器错误:将 JavaScript 对象传递给 C#
- 为什么我的 rails AJAX 请求会抛出内部服务器错误
- 500 asp.net 内部服务器错误
- 500 内部服务器错误:无法更新猫鼬中的用户
- 在尝试将插入值从javascript调用到Visual Studio中的sql服务器时,收到内部服务器错误500