繁体   English   中英

使用未解析的标识符“GraphRequestHTTPMethod”

[英]Use of unresolved identifier 'GraphRequestHTTPMethod'

我试图在集成 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.
            }
        }
    }
}

您需要使用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 "; 宽度 = 200; }; }, "last_name": Kumbhani, "first_name": Nikunj]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM