I was debugging an older script and came to the part where it should query a some Data of a Facebook user and store it into a Database.
Some of the scopes like publish_stream have been deprecated and so i replace it with "publish_actions". At least there is something i couldn't figure out. I would like to query the first and last name of the user but this reponse stays empty, the only that works is the thumbnail and the user ID.
So here are the scopes (i know public_profile is not necessary but facebook recommends it).
//function handleFacebookAuth(callback) {
function handleFacebookAuth(callback) {
var permissions = '';
//noinspection JSUnresolvedVariable
if (window.extendedPerms) {
permissions = 'public_profile,email,publish_actions,user_likes,' + window.extendedPerms;
} else {
permissions = 'public_profile,email,publish_actions';
}
if (accessToken != null && userId != null) {
callback(accessToken, userId);
} else {
FB.login(function (response) {
if (response.authResponse) {
userId = response.authResponse.userID;
accessToken = response.authResponse.accessToken;
callback(accessToken, userId);
} else {
$("#white-wall").hide();
}
}, {scope: permissions});
}
return false;
}
And here the query to the Data
function sendData(moves, seconds) {
FB.api('/me', function (response) {
var data = {
access_token: accessToken,
flag: 'data',
fbuid: response.id,
moves: moves,
seconds: seconds,
fname: response.first_name,
lname: response.last_name,
email: response.email,
gender: response.gender
};
userId = response.id;
$.ajax({
url: "ajax.php",
data: data, dataType: 'html', method: "post",
error: function (data) {
alert(data.responseText);
},
success: function (data) {
console.log(data);
//$( "#gameresults" ).html( data);
$('#gameresults').html(data);
$("#triggerbtn").fancybox({
'width': 480,
'height': 550,
'autoSize': false,
'overlayShow': false,
'scrolling': 'no'
});
$("#triggerbtn").trigger('click');
//window.top.location.href = data;
}
});
});
}
I hope that maybe someone see a mistake in it, i really can't figure out what is wrong with it, maybe the issue might be somewhere else and it would be great to hear that my code above is okay.