我有FBSDK共享功能使用以下代码:
if (FBSDKAccessToken.currentAccessToken() != nil) {
// User is already logged in, do work such as go to
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: self.url_string)
content.contentTitle = self.title_text
content.contentDescription = self.desc_text
content.imageURL = NSURL(string: "http://image.png")
let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content
button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 30)
button.center = self.view.center
self.view.addSubview(button)
}
问题在于我没有imageURL,我直接从应用程序的相机功能中获取图像,存储为UIImage变量。如何在不在线托管图像的情况下将图像附加到此FBSDKShareLinkContent?我正在使用FBSDKShareLinkContent,因为我还分享了一个标题和链接的链接。描述
编辑,我正在尝试使用此代码尝试FBSDKSharePhoto(如有人建议的那样),这样我就可以发布照片,但即使content.contentURL
已定义,我也无法正确链接网址就像以前一样。
let photo : FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = self.scaledImage
photo.userGenerated = true
let content : FBSDKSharePhotoContent = FBSDKSharePhotoContent()
content.contentURL = NSURL(string: self.url_string)
content.photos = [photo]
let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content
button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 30)
button.center = CGPointMake(self.view.center.x, self.descLabel.center.y + 51 + 30) // 51 = 1/2 of height of descLabel, 30 = space below
self.view.addSubview(button)
答案 0 :(得分:1)
似乎FBSDKSharePhotoContent
是要走的路,但目前有一个Facebook知道的错误,这导致了图像&链接不能一起工作。
https://developers.facebook.com/bugs/949486035103197/
他们说这应该在下一个Facebook应用更新版本v31中更新。 v30于5月7日更新,FB每两周发布一次更新,所以我会在一周后再回来确认功能是否已修复。