gpt4 book ai didi

swift - 适用于 Swift 5 和 Facebook SDK 5 的 Facebook GraphRequest

转载 作者:行者123 更新时间:2023-11-28 07:25:50 26 4
gpt4 key购买 nike

我最近在我的项目中将我所有的 pods 和 swift 语言更新为 Swift 5 并且收到了大量错误消息,我已经慢慢解决了这些错误消息。

然而,我正在努力解决这个问题,Facebook GraphRequest 之前工作得很好,特别是这个错误消息是在 GraphRequest< 的 version 参数上.

enter image description here

如果我删除 version 参数,则会收到此错误:

enter image description here

func fetchFacebookAttributes(fetchFBAttrbComplete: @escaping (Bool, String) -> ()){


let graphRequestConnection = GraphRequestConnection()

let graphRequest = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, picture.type(large), first_name, last_name, gender, birthday"], tokenString: AccessToken.current?.tokenString, version: .defaultVersion , httpMethod: .get)

graphRequestConnection.add(graphRequest) { (httpResponse, result) in

switch result {

case .success(response: let response)://handling .success response case

guard let responseDictionary = response.dictionaryValue else { return }


//parse response code here...


case .failed(let error):

print (error)
fetchFBAttrbComplete(false, "")
break

}//end switch

}//end graphRequestConnection

graphRequestConnection.start()//start connection


}//end func

我看到这个 FB 文档显示了如何使用它的示例,但我也很难理解它是如何使用的?这是一个单独的文件吗?

https://developers.facebook.com/docs/swift/graph/

最佳答案

为 Swift 5 试试这个:

let graphRequest = GraphRequest(graphPath: "me", parameters: ["fields": "id, email, name, picture.type(large)"], tokenString: AccessToken.current?.tokenString, version: Settings.defaultGraphAPIVersion, httpMethod: HTTPMethod.get)

关于swift - 适用于 Swift 5 和 Facebook SDK 5 的 Facebook GraphRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56625462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com