发贴到Facebook墙使用图表api [英] Posting to facebook wall using graph api

查看:119
本文介绍了发贴到Facebook墙使用图表api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用以下代码片段。

  var body = {
message:'这是一个测试消息',
image:'http:// someurltoimage。 png'
};

FB.api(
/ me / feed,
POST,
{
object:{
消息:body.message,
picture:body.image
}
},
函数(响应){
if(response&& response.error){
// process when success
}
}
);

但是我收到以下错误代码。

 错误:对象
代码:100
error_subcode:1349125
消息:参数无效
类型:FacebookApiException

此错误没有文档。



任何建议将不胜感激。

解决方案

我在尝试使用图形API将图像发布到Facebook墙上。




  • 您是使用 / feed ,要上传一张照片,您必须使用使用 /照片呼叫

  • 您正在发送无效的参数对象其中包含您的参数,对于Facebook,API不知道您的参数对象是一个对象(我知道,太多对象在这里,在另一个方式,你在一个对象内发送一个对象



要解决所有这些,请替换 me / feed 我/照片和第3参数(您的对象)与正文

  var body = {
消息:'这是一个测试消息',
url:'http://someurltoimage.png'
};

FB.api(/ me / photos,
POST,
body,
function(response){
if(response& amp ;&!response.error){
// process when success
}
}
);


I'm trying to post a text with image to facebook wall using graph api.

I'm using following code snippet for this.

 var body = {
      message : 'this is a test message',
      image : 'http://someurltoimage.png'
 };

 FB.api(
        "/me/feed",
        "POST",
        {
            "object": {
                "message": body.message,
                "picture": body.image
            }
        },
        function (response) {
          if (response && !response.error) {
              //process when success
          }
        }
    );

But I'm getting following error code.

 error: Object
 code: 100
 error_subcode: 1349125
 message: "Invalid parameter"
 type: "FacebookApiException"

There's no document for this error.

Any advise will be appreciated.

解决方案

"I'm trying to post a text with image to facebook wall using graph api."

  • You are using /feed, to upload a photo you have to use /photos call
  • You are sending an invalid parameter object which contains your parameters, to Facebook, the API doesn't know that your parameter Object is an object (I know, too many objects here, in another way, you're sending an object within an object

To solve all this, replace me/feed with me/photos and the 3rd argument (your object) with the body

 var body = {
      message : 'this is a test message',
      url: 'http://someurltoimage.png'
 };

 FB.api("/me/photos",
        "POST",
        body,
        function (response) {
          if (response && !response.error) {
              //process when success
          }
        }
 );

这篇关于发贴到Facebook墙使用图表api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆