Page 3 of 3

Issue with Facebook API

Posted: Thu Jul 17, 2014 4:02 am
by Cody Blue

Thanks Yuri - much appreciated. I should have looked at the implementation bit more carefully.


Issue with Facebook API

Posted: Tue Oct 28, 2014 11:44 pm
by rodzeus

Hi, I am having the same problems. It is logging me into Facebook but if I add the publish_actions to the scope, it is not loading the page at all. What am I doing wrong? Thanks. Here is my code below:

(function(context) {
Helper = {};
var ref;
// var projectId = window.location.href.split("/")[5];

Code: Select all

 Helper.init = function() { 

     var callbackUrl = "[url=http://appery.io/app/view/]http://appery.io/app/view/[/url]" + Facebook_Settings.project_id + "/Login.html?targetPage=Facebook_Me"; 

var url = "https://www.facebook.com/dialog/oauth...=" + Facebook_Settings['client_id'] + "&redirect_uri="

  • encodeURIComponent(callbackUrl) + "&scope=user_hometown,publish_actions&response_type=token";

    Code: Select all

     if (this.isPhoneGapApp()) { 
         ref = window.open(url, '_blank', 'location=yes'); 
         ref.addEventListener("loadstart", this.getAccessToken); 
     } else { 
         window.open(url, "_self"); 
    
     } 

};

Code: Select all

 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('a href="http://" rel="nofollow"http:///a') === -1 && document.URL.indexOf('a href="https://" rel="nofollow"https:///a') === -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);


Issue with Facebook API

Posted: Thu Oct 30, 2014 12:53 am
by Yurii Orishchuk

Hi rodzeus,

It's hard to say what is wrong now,

Please give us your app public link and describe steps to reproduce this problem.

We will take a look.

Regards.