I'm using a PhoneGap plugin to log in with Facebook, it's working perfectly, I can get the email and user id, now I needed to put that data in a JSON so I could work with it via ajax.
follow the code:
HTML
<div class="event listening button" onclick="login();">Logar com Facebook</div>
<div class="event listening button" onclick="apiTest();">Mostrar Dados</div>
<div class="event listening button" onclick="logout();">Fazer Logout</div>
JS
var login = function () {
if (!window.cordova) {
var appId = '305528339609022';
facebookConnectPlugin.browserInit(appId);
}
facebookConnectPlugin.login( ["email"],
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) });
}
var apiTest = function () {
facebookConnectPlugin.api( "me/?fields=id,email", ["user_birthday"],
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) });
}
var logout = function () {
facebookConnectPlugin.logout(
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) });
}
can see that I make login()
after clicking the show data , an alert will appear for me showing the data. Now, I needed to put it in an array, to get via ajax ...
You can see in the air
RIGHT NOW I GET THE DATA, IT IS OBJECT
MY OBJECT
var apiTest = function () {
facebookConnectPlugin.api( "me/?fields=id,email", ["user_birthday"],
function (response) {
dados = response;
});
}
The object is called "data", how can I get that object and make a json_enconde()
?