Is there any Facebook plugin for Phonegap 2.7.0?
When we try the below one, we are end up with deprecated error on Phonegap 2.7.0.
https://github.com/phonegap/phonegap-facebook-plugin/blob/master/README.md
We couldn't find anything when we Google it.
Thank you,
Sid
I would suggest you use the inappbrowser plugin that comes with phonegap to do this .. example shown below. Fill in the xxx below with your relevant info
var my_client_id = "xxxxxx", // YOUR APP ID
    my_secret = "xxxxxxxxx", // YOUR APP SECRET 
    my_redirect_uri = "https://www.facebook.com/connect/login_success.html", // LEAVE THIS
    my_type ="user_agent", my_display = "touch"; // LEAVE THIS
var facebook_token = "fbToken"; // OUR TOKEN KEEPER
var ref; //IN APP BROWSER REFERENCE
// FACEBOOK
var Facebook = {
    init:function(){
         // Begin Authorization
         var authorize_url = "https://www.facebook.com/dialog/oauth?";
         authorize_url += "client_id=" + my_client_id;
         authorize_url += "&redirect_uri=" + my_redirect_uri;
         authorize_url += "&display=" + my_display;
         authorize_url += "&scope=publish_stream";
             //CALL IN APP BROWSER WITH THE LINK
         ref = window.open(authorize_url, '_blank', 'location=no');
         ref.addEventListener('loadstart', function(event){
             Facebook.facebookLocChanged(event.url);
          });
    },
    facebookLocChanged:function(loc){
        if (loc.indexOf("code=") >= 1  ) {
            //CLOSE INAPPBROWSER AND NAVIGATE TO INDEX
            ref.close();
            //THIS IS MEANT TO BE DONE ON SERVER SIDE TO PROTECT CLIENT SECRET
            var codeUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+my_client_id+'&client_secret='+my_secret+'&redirect_uri='+my_redirect_uri+'&code='+loc.split("=")[1];
            console.log('CODE_URL::' + codeUrl);
            $.ajax({
                url: codeUrl,
                data: {},
                type: 'POST',
                async: false,
                cache: false,
                success: function(data, status){
                    //WE STORE THE TOKEN HERE
                    localStorage.setItem(facebook_token, data.split('=')[1].split('&')[0]);
                    },
                error: function(){
                    alert("Unknown error Occured");
                }
            }); 
        }
    }
I would add more functions for logout and posting to a wall etc. You can find documenatation on the inappbrowser here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With