如何使用FBSDKShareOpenGraphObject在Facebook中共享链接?

时间:2018-10-03 13:59:44

标签: ios swift facebook-graph-api

这是我的代码:

    let properties:  [String : Any] = [
                "og:type": "website",
                "og:url" : URL(string: "My Url") as Any,
                "og:title": "My title",
                "og:description": "My Description",
                "og:image" : URL(string: "Image URL") as Any,
            ]
     //GraphObject
     let object : FBSDKShareOpenGraphObject = FBSDKShareOpenGraphObject.init(properties: properties)

     //Create an action
     let action : FBSDKShareOpenGraphAction = FBSDKShareOpenGraphAction()
     action.actionType = "link"
     action.setObject(object, forKey: "website")

      // Create the content
     let content : FBSDKShareOpenGraphContent = FBSDKShareOpenGraphContent()
     content.action = action
     content.previewPropertyName = "website"

     //Show Dialog
     let dialog = FBSDKShareDialog.init()
     dialog.mode = FBSDKShareDialogMode.native
     if (!dialog.canShow()) {
            dialog.mode = FBSDKShareDialogMode.browser
     }
     dialog.shareContent = content
     dialog.fromViewController = self
     dialog.show()

我收到此错误:“动作类型链接无效”。

在使用“ FBSDKShareLinkContent”发布标题,描述和图像之前。我将Facebook SDK升级到“ 4.36.0”。在FBSDKShareLinkContent类imageURL中更新的SDK中,不再提供contentTitle和contentDescription。

0 个答案:

没有答案
相关问题