如何在Facebook登录中访问user_location?

时间:2017-04-29 13:55:40

标签: ios swift facebook-graph-api facebook-login

我正在申请这样的权限:

import requests
import json, requests
import _json

def poloniexapi(url):
    response = requests.get(url)
    json_obj = json.loads(response.text)

    for i in json_obj:
        print(i["quoteVolume"])

    total = sum([int(num) for num in i["quoteVolume"]])

poloniexapi("https://poloniex.com/public?command=returnChartData&currencyPair=BTC_XMR&start=1405699200&end=9999999999&period=86400")

注册后,我可以看到它要求我输入user_location:

fbLoginManager.logIn(withReadPermissions: ["public_profile", "email", "user_friends", "user_location"], from: self) { (result, error) in

})

但似乎缺少关键:

let request = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"first_name, last_name, user_location"], httpMethod: "GET")
                request?.start(completionHandler: { (connection, result, error) -> Void in
                    if ((error) != nil)
                    {
                        // Process error
                        print("Error: \(String(describing: error))")
                    }
                    else
                    {
                        print(result!)
                    }
                    let data:[String:AnyObject] = result as! [String : AnyObject]

但根据文档,它应该在用户对象上。感谢

1 个答案:

答案 0 :(得分:0)

  

但根据文档,它应该在用户对象上。

不,它不应该。

您将权限的名称 - user_location - 与user对象的实际字段名称 - location混淆。

https://developers.facebook.com/docs/graph-api/reference/user/

  

location
  第
  此人在其个人资料中输入的当前位置。此字段与签到无关