Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

Hello,

Here is a screenshot from my developer.facebook app settings. And also, here is a screenshot of my data mapping for this service. The request is from the local storage variables, access_token.

I will also note that I deleted the auto-generated Facebook_me page from the project, and I made changes to the facebook_helper.js file. This is were I made this changes, changing the page info to 'homePage';

(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 + "/homePage.html"; 
     var url = "[url=https://www.facebook.com/dialog/oauth?client_id]https://www.facebook.com/dialog/oauth...[/url]=" + 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('homePage', {}); 

     } 

 }; 

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

I also changed the the website/platform URL in Facebook settings to '/homePage.html'

Thanks again for your help.

Image Image

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Issues with Facebook data mapping

Hello,

This facebook API has mandatory parameter "access_token".
Thus if you test it in the "test" tab you should pass this parameter too, if you have it.
If you don't have it you can't to test it in "Test" tab.
So you should to test it on real app(make login before test to get "access_token") and call "facebook_me" service after.

Please test it and show us your requests to the facebook(make screen shots where we can see request parameters) and we'll tell you what is wrong in your implementation.

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

I apologize, but I have no idea what this means,

"So you should to test it on real app(make login before test to get "access_token") and call "facebook_me" service after."

Are we merely having a language translation issue here, or am I crazy?

Honestly, I feel this is directly related to me deleting the automated Facebook_Me page that gets generated when you add the Facebook API plugin. I shared the changes I made in the facebook_helper.js file, and changed the targets.

Again, here are my screenshots; Image Image

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

Here are the edits I made in the facebook_helper.js file Image

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

Here is the facebook_me service perma response mapping. Image

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

To complicate things further....

My users have two registration options;

  1. Create a new user account (where I have a user registration DB set up for "users")

    or

  2. Sign In with Facebook (using the FB API plug-in)

    How can I merge the two into one DB? Regardless of how they sign-in to the app.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Issues with Facebook data mapping

Hello,

You can't test "Facebook_MeService" at the test tab without passing "access_token" to it (Fill Request parameter "access_token" field with value).

Thus you should test it in app (not in test service tab).

Please try to do these:

1 Open your APP in browser.

2 Login to FaceBook with your APP.

3 Make actions in accordance to your logic to invoke facebook_me service.

4 Open browser debugger (http://docs.appery.io/documentation/d...) at the Network tab find a request to facebook_me service.

5 Make screen shots of request parameters and response. And give them to us.

If you have some problem with these steps please describe in details.

Currently it's hard to understand what problem you have.

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Issues with Facebook data mapping

I apologize for my confusion. Facebook just released their Graph v2.0 and there's a scheduled Appery webinar on the 14th that discusses the FB API and, I believe, using oAuth.io instead of the Plugin. I'll be attending this and looking into different options. If I have issues after, I'll chime back in here.

Thank you again for all your help. I really appreciate it.

Return to “Issues”