I have a facebook connect button set up with Javascript using FB.login on my website so the users profile image and name shows etc.. without refreshing the page. Here is a small piece of the code:
function updateButton(response) {
button = document.getElementById('fb-auth');
userInfo = document.getElementById('user-info');
if (response.authResponse) {
//user is already logged in and connected
FB.api('/me', function(info) {
login(response, info);
});
button.onclick = function() {
FB.logout(function(response) {
logout(response);
});
};
But I also have a system so when the user clicks (or has previously) liked my facebook page, the user of my website gets points added to their account (on my website) - error checks in place etc..
My problem is, in order for the like system to work they need permissions to be accpeted. Although they do accept these when they first login, they also seem to need to keep logging in via the Javascript SDK button for the like to work.
If they have not logged in via the JS SDK and go to click on the embedded like button on my site, it asks them to login and when they do any my code runs for the like system, an error shows which is an oAuth error (meaning they have not got a valid access token/ have not logged in).
My question is, I am not sure if the user should keep logging in when they re-visit my site, and for that matter, why does the user need to have logged in specifically through the Javascript SDK FB.login function?