I am trying to fetch facebook user email for my app. But when i query the email address is returned as null.
Forums suggest that the user should grant the email permission to your app. How to make user grant that permission or ask him what fields will he give access to the application.
I am able to get name but not email from the code below.
FB.api(
{
method: 'fql.query',
query: 'SELECT name, email FROM user WHERE uid='+FB.getSession().uid
},
function(response) {
alert(response[0].name);
}
);
its prettry simple my dear just take permission at the time of login.
<fb:login-button perms="email" autologoutlink="true"></fb:login-button>
and take other permissions in perms with comma seperated values. I hope it will help
Related
I'm trying to allow user that logged with phone firebase auth to put his email.
Note: I don't mean I want to login by email. I mean only put the email to the user auth information if possible.
To set a user's email address you can do:
var user = firebase.auth().currentUser;
user.updateEmail("user#example.com").then(function() {
// Update successful.
}).catch(function(error) {
// An error happened.
});
I am trying to use facebook Graph API to fetch user details.
Below is my FB.api query :
FB.api('/me', 'GET', { access_token: token, fields:'id,name,email,gender,location,likes' }, function(response) {
console.log(response);
alert(response);
});
With above query i am able to fetch id, name and gender but not location, email and likes.
Version for FB SDK : v2.5
I think the issue is related to some permissions required to fetch such private data of user.
Please suggest what need to be done to get all the data.
You need to ask for the permissions in the login process, with the scope parameter. Here is a list of those: https://developers.facebook.com/docs/facebook-login/permissions
HereĀ“s how to use FB.login with additional permissions:
FB.login(function(response) {
if (response.authResponse) {
//user just authorized your app
document.getElementById('loginBtn').style.display = 'none';
getUserData();
}
}, {scope: 'email,user_likes,user_location'});
Source: http://www.devils-heaven.com/facebook-javascript-sdk-login/
Make sure you read about Login Review too: https://developers.facebook.com/docs/facebook-login/review
I'm currently using hello.js to have users create accounts and sign in with facebook. However, I need to use the user's facebook email address since this is used to send the user a confirmation of purchase.
Because the user can choose to not allow us to have his/her email address, I am left with an empty slot, thus the user never receiving confirmation of orders or downloadable files purchased through the system.
I've tried using the facebook user ID, but the email format is username#facebook.com. I can retrieve the user's ID and email (if allowed), but not the username.
Can we retrieve this and if so, how ?
I scratched my head too on how to fetch emails from FB, cause the response object in the documentation [https://developers.facebook.com/docs/facebook-login/web] paragraph Make API calls looks different from what it is returned.
You may want to look at:
[https://developers.facebook.com/docs/javascript/reference/FB.api]
and add parameters.
Here using version 2.5:
window.fbAsyncInit = function() {
FB.init({
appId : {your-app-id},
status : true,
cookie : true,
xfbml : true,
oauth : true,
version : 'v2.5'
});
Following the documentation, once logged:
FB.api('/me', function(response) {console.log(response) })
response has only _ID and name despite permissions are granted.
You can retrieve the email, if existing, by also specifying fields parameters against FB.api:
FB.api('/me?fields=id,name,email', function(response) {
console.log(response);
});
I have the follwing code and would like to take the email address and other details of facebook user. This is the code that I have done.
FB.login(function(response) {
if (response.authResponse) {
//updateUserInfo(fb_id);
console.log(response.authResponse);
updateUserInfo(response.authResponse.userID);
$.ajax({
dataType: "json",
url: 'http://graph.facebook.com/'+response.authResponse.userID+'/ fields=id,name,birthday,email,gender,hometown,location',
success: function(data){
fb_data = data;
console.log(data);
}});
},{scope:'email'});
I am unable to get get the following details:
birthday
email
Location
hometown
However, I am able to get the first name and id.
If I am supposed to use the access token, how am i supposed to put it in the query? The email address is the vital information as my system identifies user by email address.
You need following permission from user to get the data from Facebook.
user_birthday for birthday
email for email
user_location for Location
user_hometown for hometown
You can check this or this for other permissions and uses.
Then you will get the access token once user click on your Login button and authorize your App.
You dont have to use the ajax call after FB.login, you can use FB.api doc , which will ensure that the access token that you have obtained while logging in (requiring email access) will be used for accessing the data
I need to pull the email addresses of all the people who are in my friendlist of facebook.
Is it possible to pull all the email address of my friends using javascript api.
It should be possible to any user, if they provide authentication.
You cannot access the email addresses of a user's friends. You can get their basic public information (user_id, display picture etc.).
To get the email address of these users, they would also have to authorise your application.
you can read the content using by sending a request to the graph api(http://developers.facebook.com/docs/reference/api/) in fb with a valid user access token ....
you can retrieve the user access token via javascript SDK
after getting that request the email of that particular user using fb.uimethods
sample code
FB.api('/', 'POST', {
batch: [
{ method: 'GET', relative_url: 'me'},
...
]
}, function (response) {
console.log(response);
});
the request url shuld be something like "https://graph.facebook.com/me?access_token=user_acess_token" & this will display the basic details about the user ...