简体   繁体   中英

Trouble setting up facebook login

I am building a hybrid mobile app based out of JavaScript, CSS and HTML. I am using the Intel XDK to develop and deploy the app.

For Facebook integration I am using the following third party plugin to work it out.

My aim is to get it to work both on iOS and Android. I have done the followings:

 <button onclick="fblogin()"> Login </button>

Script:

  <script>
    function fblogin() {    
    var fbLoginSuccess = function (userData) {
        alert("UserInfo: " + JSON.stringify(userData));
    }
    facebookConnectPlugin.login(Array strings of permissions, Function success, Function failure);


    facebookConnectPlugin.login(["public_profile"],
        fbLoginSuccess,
        function (error) { alert("" + error) }
    );

    }

        </script>

The issues: I have already enabled the plugin with my javascript api on the intel xdk. fblogin() not defined at the following line:

facebookConnectPlugin.login(Array strings of permissions, Function success, Function failure);

I have read through the guide but is still confused. I would appreciate if someone could give me a step by step guide on making this work.

I would suggest to look at the sample code on the README ( https://github.com/Wizcorp/phonegap-facebook-plugin#sample-code )

You can write your function like this:

function fblogin() {
    var fbLoginSuccess = function (userData) {
        alert("UserInfo: " + JSON.stringify(userData));
    }

    facebookConnectPlugin.login(["public_profile"],
        fbLoginSuccess,
        function (error) { alert("" + error) }
    );
}

ie remove the
facebookConnectPlugin.login(Array strings of permissions, Function success, Function failure)
line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM