How to store email address of facebook user

0 votes
Hey,

I am using Javascript SDK for my app.

I succesfully linked facebook login with my app and stored facebook user's information like Username, First Name, Last Name, but it does not stores it email-id.

How do I do that using App42?

Thanks in advance.
asked Oct 20, 2014 in App42 Cloud API-BaaS by crazyboy24 (16 points)

1 Answer

+1 vote
 
Best answer

Hello,

Right now there is no way to add the email id in linked user call. But we have record your request in our backlog and will add this in our future release. However if you need to find the email id based on access token, you can find it easily in Get Facebook Profile method of Social service.  Please find a code snippet in above link and let us know if it helps.

Thanks,

Himanshu Sharma

 

answered Oct 21, 2014 by hs00105 (2,005 points)
selected Oct 21, 2014 by crazyboy24
Not an issue you can create as an email in JSON Document. Could you please elaborate your last query so that i can provide a better support to you?
Thanks,
Himanshu Sharma
var social;
              var accessToken =  UseraccessToken;

        socialService.getFacebookProfile(accessToken,{  
            success: function(object) {  
            var response = JSON.parse(object);    
                social = response.app42.response.social;  
                console.log("facebookProfileId is : " + social.me.id)  
                console.log("facebookProfileName is : " + social.me.name)  
                console.log("facebookProfileImage is : " + social.me.picture)  
                console.log("Email Id is : " + social.me.email);
                email = social.me.email;
                name = social.me.name;
              },  
            error: function(error) {  
            }  
        });  


In the above snippet I saved user's name and email.

Now I want to save these values in json, so that I can contact them later and identify them with their email and name, as I can't see user's email-id in Business Service > Social.
Hello ,

Kindly replace your above code snippet with below code and change the data base name and collection and run:
var social;
var accessToken =  UseraccessToken,
dbName = "<Your_DataBase_Name>",
collectionName = "<Your_Collection_Name>";
var json = new Object();
var storage ;  
var storageService = App42Storage();
socialService.getFacebookProfile(accessToken,{  
    success: function(object) {  
    var response = JSON.parse(object);    
        social = response.app42.response.social;  
        email = social.me.email;
        name = social.me.name;
       
        json.name = name;
        json.email =email;
        storageService.insertJSONDocument(dbName, collectionName, json,{  
            success: function(object)
            {  
                var response = JSON.parse(object);  
                response = response.app42.response.storage;
                console.log("dbName is " + storage.dbName)
                console.log("objectId is " + storage.jsonDoc._id.$oid)
                console.log("Created At is "+storage.jsonDoc._$createdAt)
                console.log("Updated At is "+storage.jsonDoc._$updatedAt)
            },  
            error: function(error) {  
            }  
        });
    },  
    error: function(error) {  
    }  
});  

Let me know if it helps.
Thanks,
Himanshu Sharma
In the above snippet you combined Get Facebook Profile and saving JSON Object, can you please separate them, because I am first collecting facebook profile and if certain condition is true then save the name and email in the JSON Object. And it will be easier to understand.

Thanks.
Abdul.
Oops! Sorry, you din't combined the two methods, this is only for JSON object, realized it later. Sorry for the late reply.

Thanks.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...