Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

The first address worked for me when I didnt render all pages in one HTML file.

I want to render all pages in one html file so i tried using the second code instead.

This didn't work, it returned me to the facebook_Login page instead of the Facebook_Me page.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Facebook Login -- I'm getting 404 Page Not Found.

Hi Joe,

You need to use following url to get direct to goal page:

pre

//Where
// "3b5dccb5-9c7e-40f5-a674-33cf6c4280b4" - is your GUID.
// "Facebook_Login" - is your app start page.
// "Facebook_Me" - is a goal page.

http://appery.io/app/view/3b5dccb5-9c7e-40f5-a674-33cf6c4280b4/Facebook_Login.html#Facebook_Me

/pre

Regards.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

pre(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/dcf7185a-46d7-40a4-8658-6912eacd45ac/Login.html#facebookUser"; 
     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('facebookUser', {}); 

     } 

 }; 

 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);

/pre

Facebook dev:
Image

after clicking the facebook button in the tester:
Image

Image

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

my start page is "Login"
my goal page is 'facebookUser"

I'm not sure what I am doing wrong here

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Facebook Login -- I'm getting 404 Page Not Found.

Hi Joe,

Unfortunatly facebook login processing could not accept hashes (#) in the url.

I can see only one way to workaround it (if you want to use render all pages in one template).

  1. Add to your start page handle of some URL parameter like "?loginedWithFaceBook=true".

  2. URL will be "http://appery.io/app/view/93534752-d9..."

  3. On page show for start page - get this URL parameter if it exists - make navigateTo("facebookUser") page.

    Regards.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

how would I implement this using appery builder?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Facebook Login -- I'm getting 404 Page Not Found.

Hi Joe,

As described above. Unfortunatly we don't have such implementation example.

Also you can uncheck "render all pages in one template" option..

It's up to you what to choose.

Regards.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

[quote:]
" 1. Add to your start page handle of some URL parameter like "?loginedWithFaceBook=true". "
[/quote]

where do i add this? in the Facebook_Helper javascript file or somewhere else?

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

Facebook Login -- I'm getting 404 Page Not Found.

Thanks, I had tried a few things.

Just to clarify for others who are looking for the same solution.

have 'Render all pages in one HTML file' checked under app settings.

Adjust call back url in the Facebook_Helper file to http://appery.io/app/view/YourAppID/Y....

also add page show event to your start screen page, run JS:

preif (window.location.search.indexOf('loggedWithInFaceBook=true') -1) {
Appery.navigateTo('YourDestinationPage');
}
else {

}/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

Facebook Login -- I'm getting 404 Page Not Found.

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&quot 
     var url = "https://www.facebook.com/dialog/oauth?client_id=" + Facebook_Settings['client_id'] + "&redirect_uri=" + callbackUrl + "&scope=&response_type=token&quot 

     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

Return to “Issues”