Hi Joe,
I hope you dont mind me asking, I been trying to implement facebook login with an app that is rendered in one html.
I followed you post above but I am getting "Page not found (404)"
would you mind to throw you eye over my facebook helper code and code run on Facebook_Me.html pageshow event
code(function(context) {
Helper = {};
var ref;
// var projectId = window.location.href.split("/")[5];
Code: Select all
Helper.init = function() {
var callbackUrl = "http://appery.io/app/view/14d09d66-032b-4d3f-b4e4-0a9c0cfe9744/Facebook_Me.html?loggedInWithFaceBook=true"
var url = "https://www.facebook.com/dialog/oauth?client_id=" + Facebook_Settings['client_id'] + "&redirect_uri=" + callbackUrl + "&scope=&response_type=token"
if (this.isPhoneGapApp()) {
ref = window.open(url, '_blank', 'location=yes');
ref.addEventListener("loadstart", this.getAccessToken);
} else {
window.open(url, "_self");
}
};
Helper.getAccessToken = function(event) {
if (event.url.indexOf('access_token') >= 0) {
console.log("Extracting access_token...");
var params = event.url.split("access_token=");
var _access_token = params[1].slice(0, params[1].indexOf("&"));
localStorage.setItem('access_token', _access_token);
ref.close();
Appery.navigateTo('Facebook_Me', {});
}
};
Helper.isPhoneGapApp = function() {
return (document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1);
};
if (window.location.href.indexOf("access_token") != -1) {
var hashFromFb = window.location.hash;
window.location.hash = '';
var paramsFromFb = hashFromFb.substring(1).split("&");
var access_token = paramsFromFb[0].split("=")[1];
localStorage.setItem('access_token', access_token);
}
context.Helper = Helper;
})(window);/code
and page show event
codeif (window.location.search.indexOf('loggedWithInFaceBook=true') > -1) {
Appery.navigateTo('Facebook_Me.html');
}
else {
}/code
Thanks in advance!
Michael