Getting information from Facebook inside PhoneGap Build

Edited by JesseMonroy650:

I have already made several hybrid applications, although none of them were commercially available. I am using PhoneGap Build. Located here: https://build.phonegap.com/ I do not use a desktop application.

Source text:

I am trying to get data from Facebook inside the PhoneGap assembly.

I have a simple script that seems to work based on the API :

<script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var fbLoginSuccess = function(userData) { alert("UserInfo: " + JSON.stringify(userData)); facebookConnectPlugin.getAccessToken(function(token) { alert("Token: " + token); }, function(err) { alert("Could not get access token: " + err); }); } facebookConnectPlugin.login(["public_profile"], fbLoginSuccess, function(error) { alert("" + error) } ); } </script> 

And I believe that I configured my config.xml correctly:

 <gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0"> <param name="APP_ID" value="<ACTUAL APP ID HERE>" /> <param name="APP_NAME" value="<ACTUAL APP NAME HERE>" /> </gap:plugin> 

But I don't get any warnings about this (or in the console log when I try to do this).

  • So my question is: am I using the PhoneGap Build Facebook API correctly? What should I do differently?

  • This is a less important issue - bonus points, if someone can indicate how I can get the same process that works in the browser without installing Cordoba locally - if possible even

+6
source share
2 answers

For your first question:

Add below config.xml to your file and make sure you put your config.xml file in the root folder with your index.html file:

 <gap:plugin name="com.phonegap.plugins.facebookconnect"> <param name="APP_ID" value="..." /> <param name="APP_NAME" value="..." /> </gap:plugin> 

Add to your index.html file and each .html file that you want to access the plugin scripts:

 <script scr="phonegap.js"></script> <script src="cdv-plugin-fb-connect.js"></script > <script src="facebook-js-sdk.js"></script > 

Now read and follow the documentation located here . Be sure to pay attention to the paragraph under the heading "Requirements and setup of Facebook."

Once complete, upload your zipped project to build.phonegap.com and wait for your project to compile.

For your second question:

It is not possible to check it in a browser by any means without installing Cordova. This is currently out of the box

+2
source

I think you have some semicolons (e.g. declaring fbLoginSuccess var), try with this code

 <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var fbLoginSuccess = function (userData) { alert("UserInfo: " + JSON.stringify(userData)); facebookConnectPlugin.getAccessToken(function (token) { alert("Token: " + token); }, function (err) { alert("Could not get access token: " + err); }); }; facebookConnectPlugin.login(["public_profile"], fbLoginSuccess, function (error) { alert("" + error); } ); } </script> 
+2
source

All Articles