我知道,当通过iOS应用程序发布到Facebook时,应用程序需要在写入之前进行读取,即读取用户电子邮件,然后才能发布到墙上.我知道这些权限列表不能在同一个请求中完成.所以我拼凑了看起来如下的代码.
class func postToFacebook(message: String,appID: String){ var accountStore = ACAccountStore() var accountType = accountStore.accountTypeWithAccountTypeIDentifIEr(ACAccountTypeIDentifIErFacebook) var optionsForPosting = [ACFacebookAppIDKey:appID,ACFacebookPermissionsKey: ["email"],ACFacebookAudIEnceKey: ACFacebookAudIEnceFrIEnds] accountStore.requestAccesstoAccountsWithType(accountType,options: optionsForPosting) { granted,error in if granted { var options = [ACFacebookAppIDKey:appID,ACFacebookPermissionsKey: ["publish_stream","publish_actions"],ACFacebookAudIEnceKey: ACFacebookAudIEnceFrIEnds] accountStore.requestAccesstoAccountsWithType(accountType,options: options) { granted,error in if granted { var accountsArray = accountStore.accountsWithAccountType(accountType) if accountsArray.count > 0 { var facebookAccount = accountsArray[0] as ACAccount var parameters = Dictionary<String,AnyObject>() parameters["access_token"] = facebookAccount.credential.oauthToken parameters["message"] = message var FeedURL = NSURL(string: "https://graph.facebook.com/me/Feed") let posts = SLRequest(forServiceType: SLServiceTypeFacebook,requestMethod: SLRequestMethod.POST,URL: FeedURL,parameters: parameters) let handler: SLRequestHandler = { (response,urlResponse,error) in println(response) println(urlResponse.statusCode) } posts.performRequestWithHandler(handler) } } else{ println("Access denIEd") println(error.localizedDescription) } } } else{ println("Access denIEd") println(error.localizedDescription) } }}
不幸的是我还在
The Facebook server Could not fulfill this access request: InvalID permission: publish_stream
我已经在Facebook开发站点上设置了我的应用程序,并且我还在开发站点添加了正确的包标识符.
解决方法 好的,所以答案是“publish_stream”似乎不是作为权限工作,尽管许多教程使用它. 总结以上是内存溢出为你收集整理的使用Swift从iOS应用程序发布到Facebook全部内容,希望文章能够帮你解决使用Swift从iOS应用程序发布到Facebook所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)