Facebook用户位置使用fb.api [英] Facebook user location using fb.api

查看:614
本文介绍了Facebook用户位置使用fb.api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想允许我的用户使用Facebook登录,而当用户这样做时,我想要收集姓名,电子邮件,位置,性别等信息。我面临的两个问题是

I want to allow my user's to login with facebook and while user do that i want to collect there information such as Name,Email,Location, Gender etc. There are two issues that i am facing


  1. FB.api不总是返回用户的位置。

  2. 我无法使用user_birhtday获取用户的生日。代码如下。

  1. FB.api not always returns me user's location.
  2. I am not able to get the user's birthday using user_birhtday. Code is given below.

FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        FB.api('/me?fields=age_range,name,location,email,gender', function(response) {
            //Get the user's Information
        });
    } else {
        FB.login(function(response) {
            if (response.authResponse) {
                FB.api('/me?fields=age_range,name,location,email,gender', function(response) {
                    //Get the user's Information
}); } else { // User is not logged in } }, { scope : 'email'}); } }, true); }


推荐答案

你有一个非常清楚的权限列表,您必须要求查询用户数据的各个部分。请参阅用户页面的权限部分(滚动到页尾)并将它们添加到您的作用域参数中。

You have a very clear list of permissions that you have to ask to query various parts of user data. Refer to the permissions section on user page (scroll to the end of page) and add them into your scope parameter.

对于生日和位置,您必须进行以下更改:

For birthday and location you have to make the following change:

-- scope : 'email' 
++ scope : ['email','user_birthday','user_location']

并添加


生日

birthday

字段到您的字段列表。

这应该可以解决您的问题。

This should solve your problem.

这篇关于Facebook用户位置使用fb.api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆