Facebook Swift SDK:使用应用访问令牌

时间:2017-11-13 21:49:29

标签: swift facebook facebook-sdk-4.0

在我的应用程序中,我想使用我的App Access Token拨打公共活动。如何将当前的AccessToken设置为我的App Access Token? Facebook登录时似乎自动设置了AccessToken,但我无法找到手动设置令牌的位置。

我试图以这种方式使图表工作:

struct MyProfileRequest: GraphRequestProtocol {
    var accessToken: AccessToken? = AccessToken(authenticationToken: "XXX")
    // Assume my App Access Token works, as it does in the Token Tool. Token got from https://developers.facebook.com/tools/access_token/

    var parameters: [String : Any]?

    struct Response: GraphResponseProtocol {
        init(rawResponse: Any?) {
            // Decode JSON from rawResponse into other properties here.
        }
    }

    var graphPath = "/562230910790496"
    var httpMethod: GraphRequestHTTPMethod = .GET
    var apiVersion: GraphAPIVersion = .defaultVersion
}

... // Somewhere in a ViewController

let connection = GraphRequestConnection()
connection.add(MyProfileRequest()) { httpResponse, result in
    switch result {
    case .success(let response):
        print("Graph Request Succeeded: \(response)")
    case .failed(let error):
        print("Graph Request Failed: \(error)")
    }
}
connection.start()

0 个答案:

没有答案