Facebook Open Graph - “og.likes”行动可以分配“产品”类型吗?

时间:2017-04-23 07:40:47

标签: facebook-graph-api facebook-opengraph facebook-ios-sdk

以下iOS代码(带有“og.likes”操作的“对象”类型)运行正常:

let properties = [
    "og:type": "object",
    "og:title": "Test Product",
    "og:description": "Product description"
]

let object = FBSDKShareOpenGraphObject(properties: properties)

let action = FBSDKShareOpenGraphAction()
action.actionType = "og.likes"
action.setObject(object, forKey: "object")

let content = FBSDKShareOpenGraphContent()
content.action = action
content.previewPropertyName = "object"

FBSDKShareDialog.show(from: self, with: content, delegate: nil)

但是,我更喜欢使用“产品”类型而不是通用的“对象”类型。以下代码与上面的代码相同,只是将“object”替换为“product”(所以这次试图用“og.likes”动作发布关于“product”类型的故事)

let properties = [
    "og:type": "product",
    "og:title": "Test Product",
    "og:description": "Product description"
]

let object = FBSDKShareOpenGraphObject(properties: properties)

let action = FBSDKShareOpenGraphAction()
action.actionType = "og.likes"
action.setObject(object, forKey: "product")

let content = FBSDKShareOpenGraphContent()
content.action = action
content.previewPropertyName = "product"

FBSDKShareDialog.show(from: self, with: content, delegate: nil)

此代码生成以下错误:

  

动作需要至少一个参考:你正在尝试的动作   发布无效,因为它未指定任何引用对象。   必须至少指定以下属性之一:object。

知道为什么吗?

0 个答案:

没有答案