Software Archive
Read-only legacy content
17061 Discussions

Facebook Connect Plugin

Alexander_F_
Beginner
1,373 Views

Hey can some body help me with this, I try to get email and public profile from facebook app, I included the plugin cordova facebook connect and enter my App ID and App Name, but when nothing happens when I execute this function, do not show nothing, thank you in advance.

function facebook_login(){
    //get login status
    facebookConnectPlugin.getLoginStatus(fbLoginSuccess, 
        function (error){
            alert("" + error);
        }
    );
    var fbLoginSuccess = function(data){
        alert(data);
        if(data.status == 'connected'){
            //get info
            facebookConnectPlugin.api(data.userID + "/?fields=email", ["public_profile"],
                function(result){
                    var form = document.getElementById('registerform');
                    form.email.value = data.email;
window.localStorage.setItem('fb_first_name', result.first_name);
                            window.localStorage.setItem('fb_last_name', result.last_name);
                            //load create_account_page
                            $.mobile.changePage('#create_account', {transition: 'flip'} );
                    },
                        function(error){
                            alert('Failed ' + error);
                    }
            );
        }else{
            alert(data);
            facebookConnectPlugin.login(["email", "public_profile"],
                fbLoginSuccess,
                function (error) { alert("" + error) }
            );
        }
    }
}

 

0 Kudos
9 Replies
Alexander_F_
Beginner
1,373 Views

Check this screens, when I try to login on facebook, and here is the new code, please help ASAP.

 

function facebook_login(){
    var fbLoginSuccess = function (userData) {
        alert("UserInfo: " + JSON.stringify(userData));
        //get info
        facebookConnectPlugin.api("me/?fields=id,email", ["public_profile"],
            function (result) {
                alert("Result: " + JSON.stringify(result));
            },
            function (error) {
                alert("Failed: " + error);
            }
        );
    }

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

Thank You!

 

0 Kudos
Elroy_A_Intel
Employee
1,373 Views

You are required to provide a hashkey in your Facebook application. For more information about the creation of key hashes, visit the following links as a startingpoint:

0 Kudos
David_B_12
Beginner
1,373 Views

I'm just getting this error in the chrome log when debuggon on a physical device and using AppPreview:

Uncaught ReferenceError: facebookConnectPlugin is not defined 

0 Kudos
David_B_12
Beginner
1,373 Views

So the facebook plugin only works when you do a full build and deploy to a phone.  It doesn't work when you use the Debug tab.  So the question is how are you supposed to use the debugger when you've got FB integrated as it seems to be be rather useless now?. :\

0 Kudos
John_H_Intel2
Employee
1,373 Views

Yes, you must build your app to use the fb plugin. 

0 Kudos
David_B_22
Beginner
1,373 Views

JOHN H. (Intel) wrote:

Yes, you must build your app to use the fb plugin. 

 

 

So the app is built as crosswalk for android but I'm seeing the Invalid facebook keys error still.  Where do I set/get the key?

0 Kudos
Amrita_C_Intel
Employee
1,373 Views

Can you provide some screenshots? You can refer to this article as well.

https://software.intel.com/en-us/xdk/article/facebook-connect-plugin-android-ios

0 Kudos
David_B_22
Beginner
1,373 Views

Hi Amrita.  I tried again this morning and it worked.  I created a new test facebook app on developers.facebook.com but this time I didn't add the android platform to the app as I did in the previous one.  I guess that's what might have caused the issue.

Thanks again.

0 Kudos
David_B_22
Beginner
1,373 Views

I think there is still an issue here. Here's what happens.  

1.  Build android app and deploy to device.

2.  FB connect works, my app is connected to the user.

3.  I make another build (same FB_APP_ID etc.), remove the first original build from the phone and redeploy.

4. FB connect plugin has a login status of 'unknown' as opposed to 'connected' before.  The FB window is also now shown with "This app has no Android key hashes configured. Configure your app key hashes at...".

So how do users receive updated versions of the app without removing it from their facebook settings first?  I don't understand.

 

0 Kudos
Reply