使用未解析的标识符'GraphRequestHTTPMethod'

问题描述 投票:0回答:1

我试图在集成FBSDK后获取用户详细信息。但遗憾的是我收到的错误如“使用未解析的标识符'GraphRequestHTTPMethod'”。如果有人帮助我,会很棒。谢谢!

func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
    let loginManager = FBSDKLoginManager()
    loginManager.logOut()
}
func getUserInfoFromFB() {

    let params = ["fields":"cover,picture.type(large),id,name,first_name,last_name,gender,birthday,email,location,hometown"]

    let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: params)
    graphRequest!.start {(urlResponse, requestResult) in
        switch requestResult {
        case .failed(let error):
            print("error in graph request:", error)
            break
        case .success(let graphResponse):

            if let responseDictionary = graphResponse.dictionaryValue {
                print(responseDictionary) // Respose is here.
            }
        }
    }
}
ios swift facebook-graph-api
1个回答
0
投票

你需要使用GraphRequest而不是FBSDKGraphRequest这里是工作代码(Swift 4)

import FacebookCore
import FacebookLogin

func getUserInfoFromFB() {

    let params = ["fields":"cover,picture.type(large),id,name,first_name,last_name,gender,birthday,email,location,hometown"]
    let graphRequest = GraphRequest(graphPath: "me", parameters: params)
    graphRequest.start {
        (urlResponse, requestResult) in

        switch requestResult {
        case .failed(let error):
            print("error in graph request:", error)
            break
        case .success(let graphResponse):

            if let responseDictionary = graphResponse.dictionaryValue {
                print(responseDictionary) // Respose is here.
            }
        }
    }
}

输出:

[“email”:abc @ gmail.com,“id”:1118625048361749,“name”:Nikunj Kumbhani,“picture”:{data = {height = 200; “is_silhouette”= 0; url =“https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=1118695008301542&height=200&width=200&ext=1557315519&hash=AeRP_G5QJ0Tlff-8”; width = 200; }; },“last_name”:请求,“first_name”:Nikunj]

© www.soinside.com 2019 - 2024. All rights reserved.