[英]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.