Reputation: 404
How to find user details by using his/her email ID or mobile number from Facebook? I want to get user details on my website using my app id access.
Please help me out this.
Upvotes: 0
Views: 1990
Reputation: 384
Try this. You need his facebook ID or his facebook name.
var fields = [
'id',
'name',
'first_name',
'middle_name',
'last_name',
'gender']
FB.api('/{insertIDhere}', {fields: fields}, function(details) {
// output the response
});
Or take this code from the FB Api Documentation
FB.api(
"/{user-id}",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
to login you need something like this :
FB.login(function(response) {
if (response.authResponse) {
//login successfull
} else {
//anything else
}
}, {scope: 'public_profile,email,user_friends'});
If you are logged in you could use something like this:
FB.api(
"/me?fields=id,name,picture.redirect(false).type(large)",
function (response) {
if (response && !response.error) {
facebookId = response.id;
facebookName = response.name;
facebookProfilePicture = response.picture.data.url;
callback(facebookUser);
}else{
}
}
);
Upvotes: 1
Reputation: 999
You can't. Searching by email or phone is not possible.
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.3#search
Upvotes: 0