Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过ios应用程序(Swift和FBSDK4.0.1)将照片共享到Facebook后无法获取结果帖子id_Ios_Facebook_Swift_Photo_Facebook Ios Sdk - Fatal编程技术网

通过ios应用程序(Swift和FBSDK4.0.1)将照片共享到Facebook后无法获取结果帖子id

通过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

我正在编写一个iOS应用程序来进行照片共享

使用技术Swift和FBSDK 4.0.1

我发现通过FBSDKSharephotoContent()共享照片 无法从
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)
    }
    
  • Facebook
    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")
    }