通过ios应用程序(Swift和FBSDK4.0.1)将照片共享到Facebook后无法获取结果帖子id
我正在编写一个iOS应用程序来进行照片共享 使用技术Swift和FBSDK 4.0.1 我发现通过FBSDKSharephotoContent()共享照片 无法从通过ios应用程序(Swift和FBSDK4.0.1)将照片共享到Facebook后无法获取结果帖子id,ios,facebook,swift,photo,facebook-ios-sdk,Ios,Facebook,Swift,Photo,Facebook Ios Sdk,我正在编写一个iOS应用程序来进行照片共享 使用技术Swift和FBSDK 4.0.1 我发现通过FBSDKSharephotoContent()共享照片 无法从FBSDKSharingDelegate内部方法didpleteWithResults中的结果对象获取任何帖子id。 结果对象包含空行: [:] 但是,通过FBSDKShareLinkContent()共享URL 可以从结果对象获取post id。 诸如此类: [postId: 10000844250000_1461080697500
FBSDKSharingDelegate
内部方法didpleteWithResults
中的结果对象获取任何帖子id。
结果对象包含空行:
[:]
但是,通过FBSDKShareLinkContent()共享URL
可以从结果对象获取post id。
诸如此类:
[postId: 10000844250000_146108069750000]
我的核心代码的一部分:
UIImagePickerControllerDelegate
,UINavigationControllerDelegate
)
@IBAction func postButtonClick(sender: AnyObject) {
let photoContent = FBSDKSharePhotoContent()
let photo : FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = uploadImage.image
photo.userGenerated = true
photoContent.photos = [photo]
FBSDKShareDialog.showFromViewController(self, withContent: photoContent, delegate:self)
}
FBSDKSharingDelegate
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
var theImage:UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
uploadImage.image = theImage
self.dismissViewControllerAnimated(false, completion: nil)
}
func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject])
{
println("sharer didCompleteWithResults, results.count\(results.count)")
println(results)
// still cannot get post id from photo upload
}
func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!) {
println("sharer NSError")
println(error.description)
}
func sharerDidCancel(sharer: FBSDKSharing!) {
println("sharerDidCancel")
}
let photo = FBSDKSharePhoto()
photo.image = chosenImage
photo.isUserGenerated = false
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
let shareApiInstance = FBSDKShareAPI()
shareApiInstance.message = "customized facebook content"
shareApiInstance.shareContent = photoContent
shareApiInstance.delegate = self
shareApiInstance.share()
//委托方法
func sharer(sharer:FBSDKSharing!,didCompleteWithResults:[AnyHashable:Any]!){打印(“被称为代表”)
通过上述解决方法,您可以访问postId。照片和链接共享都是由同一用户完成的吗?通常,只有用户授予您的应用程序发布操作权限,即使您使用本机共享对话框,您才能获得postId。李明,您好,是的,这两个共享都是由具有发布操作权限的同一用户完成的。因此,这很奇怪。如果您已经授予了发布权限而没有接收到ID,你可能应该在这里提交一个错误:HyLAMDADJ22,OK谢谢=)。我在这里报告@ LeoKaHoLee,发现了什么?如果你有发布行为许可,那么只有它是可能的。考虑在FBSDKSypAPI()的帮助下发布解决方案之前解释你的代码。你可以得到邮政id。
let resultsInfo = results as! [String : Any]
print(resultsInfo["postId"] as! String)
}
func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
print("sharer NSError")
print(error.localizedDescription)
}
func sharerDidCancel(_ sharer: FBSDKSharing!) {
print("sharerDidCancel")
}