简体   繁体   English

Facebook Javascript SDK open-graph:为自定义故事添加自定义对象时出错

[英]Facebook Javascript SDK open-graph: error adding custom objects for custom stories

I've created a custom object, called 'Opinion' to build custom stories around it. 我创建了一个名为“Opinion”的自定义对象来围绕它构建自定义故事。

I'm trying to add some app-owned objects from my website using the javascript sdk. 我正在尝试使用javascript sdk从我的网站添加一些应用程序拥有的对象。

The sample code facebook gives me is: facebook给我的示例代码是:

FB.api(
  'me/objects/[namespace]:opinion',
  'post',
  {
    app_id: xxxxxxxx,
    type: "[namespace]:opinion",
    url: "http://samples.ogp.me/331257847005141",
    title: "Sample Opinion",
    image: "https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png",
    description: ""
  },
  function(response) {
    // handle the response
  }
);

The reponse is an error (OAuth Exception): 响应是一个错误(OAuth异常):

2500: Cannot specify type in both the path and query parameter.

If i remove the type parameter, i get another error: 如果我删除type参数,我得到另一个错误:

(#100) The parameter object is required

Same if I remove [namespace]:opinion from the path. 如果我从路径中删除[namespace]:opinion ,则相同。

I don't understand why, and there's no reference about this after googling it. 我不明白为什么,谷歌搜索后没有任何参考。

Why this? 为什么这个? Any resource i can refer to solve that? 我可以参考解决的任何资源?

The object is a JSON-encoded version of an object, the sample code generated for you was incorrect. 该对象是对象的JSON编码版本,为您生成的示例代码不正确。 Also remove type from the parameter list. 同时从参数列表中删除类型。

So something like, 所以,像,

FB.api(
  'me/objects/[namespace]:opinion',
  'post',
  {
    object: {"app_id":xxx,"url":"http:\/\/samples.ogp.me\/331257847005141","title":"\"Sample Opinion\"","image":"https:\/\/s-static.ak.fbcdn.net\/images\/devsite\/attachment_blank.png","description":"\"\""}
  },
  function(response) {
    // handle the response
  }
);

An example of how it looks can be seen at http://philippeharewood.com/facebook/objectify.html and it was based off the curl example given at https://developers.facebook.com/docs/opengraph/using-object-api/ http://philippeharewood.com/facebook/objectify.html上可以看到它的外观示例,它基于https://developers.facebook.com/docs/opengraph/using-object上给出的卷曲示例。 -API /

For anyone struggling with a similar problem on iOS, the sample code again appears to be wrong, however the following seems to work: 对于在iOS上遇到类似问题的人来说,示例代码似乎再次出错,但以下似乎有效:

NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"<appnamespace>:<objecttype>"
    title:@"..."
    image:[result objectForKey:@"uri"]
      url:nil
  description:@"..."];

[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
    // handle the result
    if ( error ) {
        DLog(@"error %@ creating object", error);
    } else {
        ...
    }
}];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook定制故事与大图像 - 用Javascript打开图表 - Facebook custom stories with big Image - Open Graph with Javascript 像使用内置图一样的api的Facebook商业页面无法与javascript sdk一起使用 - Like facebook business page using built-in like open-graph api not working with javascript sdk 在JavaScript中发布自定义Facebook故事 - Posting custom Facebook Stories in javascript 将对象从图形api json推入数组,并在for循环中使用for循环(facebook javascript sdk / open graph) - push objects into array from graph api json with for loop in for loop(facebook javascript sdk/open graph) 发布自定义Open Graph故事时,Facebook Share Dialog无法识别自定义参考对象 - Facebook Share Dialog failing to recognize custom reference objects when posting custom Open Graph story Facebook使用自定义按钮登录javascript sdk - Facebook Login with custom button javascript sdk 自定义Facebook登录使用Javascript SDK的行为异常 - Custom Facebook Login is behaving strangely with Javascript SDK Facebook Open Graph自定义通知仅对时间轴用户可用? - Facebook Open Graph custom notifications available only to timeline users? Facebook自定义故事共享使用JavaScript sdk()显示错误(Action需要至少一个参考) - Facebook custom story share using JavaScript sdk() showing error(Action Requires At Least One Reference) 使用Yammer嵌入和打开图形设置默认目标组 - Setting default target group with Yammer embed and open-graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM