坚持使用Facebook SDK v4
和ParseHelperv4
在 Swift 中将图片发布到 FB。创建用户并使用 read persimmons 登录,我可以获得邮件名称等用户信息,因为 FBSDKAccessToken.currentAccessToken()
它总是空的,所以响应FBSDKSharingDelegate
总是你没有权限......我做错了什么吗?
let permissions : NSArray = ["publish_actions"]
PFFacebookUtils.linkUserInBackground(PFUser.currentUser(), withPublishPermissions: permissions, block: { (aBool, error) -> Void in
if aBool && error == nil {
let aToken = FBSDKAccessToken.currentAccessToken()
println(aToken.permissions) -- just for logging and it returns empty not even read permissions
let fbPhoto = FBSDKSharePhoto(image: self.topImageView.image, userGenerated: true)
let aTest : FBSDKSharePhotoContent = FBSDKSharePhotoContent()
aTest.photos = [fbPhoto]
FBSDKShareAPI.shareWithContent(aTest, delegate: self) }
})
并委托
func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!) {
println(error.description)
}
错误 Domain=com.facebook.sdk.share Code=202 “操作无法完成。(com.facebook.sdk.share 错误 202。)” UserInfo=0x16535010 {com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Share API 是无法使用。[FBSDKAccessToken currentAccessToken] 必须有 publish_actions 权限。}
我可能错过了一步......我应该以某种方式将 fbaccestoken 设置为与 pffaceookutils 链接吗?