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.
我正在尝试使用 javascript sdk 从我的网站添加一些应用拥有的对象.
I'm trying to add some app-owned objects from my website using the javascript sdk.
facebook 给我的示例代码是:
The sample code facebook gives me is:
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
}
);
响应是一个错误(OAuth Exception):
The reponse is an error (OAuth Exception):
2500: Cannot specify type in both the path and query parameter.
如果我删除 type
参数,我会得到另一个错误:
If i remove the type
parameter, i get another error:
(#100) The parameter object is required
如果我从路径中删除 [namespace]:opinion
也是如此.
Same if I remove [namespace]:opinion
from the path.
我不明白为什么,谷歌搜索后没有关于此的参考.
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?
推荐答案
对象是对象的JSON编码版本,为您生成的示例代码不正确.还要从参数列表中删除类型.
The object is a JSON-encoded version of an object, the sample code generated for you was incorrect. Also remove type from the parameter list.
比如,
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
}
);
可以在 http://philippeharewood.com/facebook/objectify.html 中查看其外观示例它基于 https://developers.facebook.com/docs/opengraph 中给出的 curl 示例/using-object-api/
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/
这篇关于Facebook Javascript SDK open-graph:为自定义故事添加自定义对象时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!