Facebook-Authentification inside PhoneGap / Android

When using PhoneGap, the application files are accessed locally (file://assets/…). Therefore the standard Facebook auth procedure using redirects does not work out of the box.
This article demonstrates the use of the PhoneGap-Facebook-Plugin.

PhoneGap + Android supports a Facebook-Plugin (by Jos Shepherd, thank you very much!). Simple insert the source (Java + JavaScript) from the Facebook-Plugin into your PhoneGap project. I had do adapt the file FacebookAuth.java to support more Capabilities (like publish_stream, …):

/**
* Display a new browser with the specified URL.
*
* @return "" if ok, or error message.
*/
public void authorize(final String appid) {
    Log.d("PhoneGapLog", "authorize");
    final FacebookAuth fba = this;
    Runnable runnable = new Runnable() {
        public void run() {
            fba.mFb = new Facebook(appid);
            fba.mFb.setPlugin(fba);
            fba.mFb.authorize((Activity) fba.ctx,
                              new String[] {
                                "publish_stream",
                                "offline_access"},
                              new AuthorizeListener(fba));

        };
    };
    this.ctx.runOnUiThread(runnable);
}

Afterwards you can authenticate Facebook from JavaScript using:

var appId = 1234; // this is your facebook app id

window.plugins.facebook.authorize(appId, function(res) {
    if(res.token !== undefined) {
        // we have a token, save it (user has authenticated before)
    } else {
        // we have to call authorize
        window.plugins.facebook.getAccess(function(res) {
            if(res.token !== undefined) {
                // we got a token (user has authenticated
                //                 just in that moment)
            }
        });
    }
});

Note that you have to register your App-Signing-Key on Facebook (App-Settings) – Mobile and Devices – Android. Otherwise this will just work in the Android Simulator, but not on a real device.

You get this Key-Signature using the following command:

keytool -exportcert -alias androiddebugkey \
        -keystore ~/.android/debug.keystore | openssl sha1 -binary \
| openssl base64

For iPhone-Deployments you need a different approach using ChildBrowser, an other PhoneGap-Plugin (by purplecabbage/Jesse, thank you!).

Stay tuned,
Gregor

This entry was posted in PhoneGap and tagged , , . Bookmark the permalink.

33 Responses to Facebook-Authentification inside PhoneGap / Android

  1. lorenzo says:

    that was really useful and lot of things now have sense…
    anyway… i have a little doubt… i added that javascript in a function linking it from a button i have in the page, something like:
    function myFB() {
    window.plugins.facebook.authorize(appId, function(res) {
    ….
    }
    }
    the weird thing is that if i click the button twice, the fb window opens up (even if it autoclose), it seems it need to check the token against FB every time (actually it never enter the “if” but always go to “else” and do the getAccess again.
    maybe once i clicked the button to auth i shoulòd remove (or hide) it, and alle the other function (for example a button to see the the feed, or other thing), should assume im authenticated?

    thank you!

  2. I solved the problem with a state variable on the server. Afterwards the user is authenticated, I get the access_token. I store the token on the server for further facebook actions.

    On application init I ask the server for the user details, which contain a flag “facebook: true”. By checking this flag, you can hide the button.
    If any action fails (like publishing to the stream) I assume the user has revoked facebook access and I start displaying the facebook auth button again.

    Hope this helps!

    Gregor

  3. lorenzo says:

    thank you for your reply
    i will have a try… anyway i dont actually use a server at the moment (i mean… this is a phonegap local app, and sits in assets)
    furthermore, what happen next time i open the app if i already granted access/authenticate? may i should save the token somewhere on the phone for the user?
    im probably missing somthing…

    • If you don’t have a server backend, you can save your data into device local storage.

      Quick example (copy and paste from PhoneGap Documentation, Section Storage):
      window.localStorage.setItem("key", "value");

      var value = window.localStorage.getItem("key");
      // value is now equal to "value"

      This value is saved into the browser’s local storage.

      What does you application do? I’m just curious.

      Gregor

  4. Mohamed says:

    Can you please list the steps to make this plugin works ??? it doesn’t work for me basically

  5. Mohamed says:

    I’m sorry i was missing something but now it works :),
    Now I have another problem , I want to perform facebook logout from my application , I tried to simulate the authorize function steps and delete the webview cookies but it doesn’t work .
    the problem is that the Logout method that I created in the FacebookAuth.java class is not called .
    I made the same application on Iphone using the childbrowser plugin and make my logout with the same steps and it works.
    So I’m wondering if you can help me with Android
    Thanks in Advance

    • How did you insert the Method into the Java Source? You have to provide a JavaScript stub inside the phonegap JavaScript, too.
      Please provide details to help you!
      regards,
      Gregor

  6. magico says:

    Great post!!

    please can you help with the FEED api?

    i want to POST somwthing onto the wall, but it simply Don’t work

    also when i Use the additional propertiese, it seems they are passed to the JAVA function

    i’m tryng this in javascript:

    window.plugins.facebook.request(“me/feed” , {“message” : “my message” }, function(res){
    // alert(res);
    });

    any help pleasE?

    thank you very much!!

    • Although I am using server side code to publish to the wall, you just can use a AJAX-Call to the feed api, but you have to specify the obtained access_token on every request!

      My sample code in Python (please inspect the returning JSON object, as it contains helpful error / status messages):

      data = "access_token=%s&message=%s&name=%s&link=%s&caption=%s&description=%s&picture=%s" % (urllib.quote(self.user.ACCESS_TOKEN),
      urllib.quote(message.encode("utf-8")),
      urllib.quote(linktitle.encode("utf-8")),
      urllib.quote(link),
      urllib.quote(subtitle.encode("utf-8")),
      urllib.quote(subtext.encode("utf-8")),
      urllib.quote(image))

      resp = urllib.urlopen(u"https://graph.facebook.com/me/feed", data=data).read()

      • Sudheer says:

        Can I have sample to post feed to facebook wall using ajax (not through server)?

  7. varsha says:

    Hi,

    I am new developer on phonegap android.
    I want to integrate facebook in phonegap android project.
    I have integrated facebook plugin in project and tried with android 2.2.
    I have added anchor button in index.html and called onclick I called this js function

    var callfacebook = function() {
    appId = 123123123 // this is your facebook app id
    alert(appId);
    window.plugins.facebook.authorize(appId ,function(res){
    alert(res.name); // the authorized users name

    window.plugins.facebook.request(“me/likes” ,function(res){
    alert(res.data[0].name); // the name of the first ‘liked’ item
    });

    });

    I got only appId alert after that nothing happned?

    What’s wrong in my case?
    If anybody have successfully completed facebook phonegap sample with android Please explain me steps “How use facebook in phonegap android project?”

    Thanks & Regards
    Varsha

    • Bohun Tak says:

      First, I must say thank you, Gregor!! for sharing your wonderful idea and implementation..

      To, Varsha, I had the same problem.
      But, after reading the Gregor’s posting carefully, I found one missing point,
      Storing App-Signing-Key on Facebook.
      You need to run the following command to get some key string. And store that in the Facebook App page you’re building.

      keytool -exportcert -alias androiddebugkey \
      -keystore ~/.android/debug.keystore | openssl sha1 -binary \
      | openssl base64

      I hope it will solve your problem..

  8. Cam says:

    How do you install the plugin?

  9. AlexM says:

    I’m getting a fatal exception for 3.0/3.1 builds:
    ERROR/AndroidRuntime(468): FATAL EXCEPTION: main
    ERROR/AndroidRuntime(468): android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
    at java.net.InetAddress.lookupHostByName(InetAddress.java:477)
    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:277)
    at java.net.InetAddress.getAllByName(InetAddress.java:249)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:69)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:48)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:304)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:292)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:274)
    at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:447)
    at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:419)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1038)
    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:523)
    at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:283)
    at com.facebook.android.Util.openUrl(Util.java:200)
    at com.facebook.android.Facebook.request(Facebook.java:584)
    at com.facebook.android.Facebook.request(Facebook.java:521)
    at com.hipsnip.plugins.facebook.FacebookAuth.getResponse(FacebookAuth.java:107)
    at com.hipsnip.plugins.facebook.FacebookAuth$AuthorizeListener.onComplete(FacebookAuth.java:271)
    at com.facebook.android.Facebook$1.onComplete(Facebook.java:333)
    at com.facebook.android.FbDialog$FbWebViewClient.shouldOverrideUrlLoading(FbDialog.java:133)
    at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:222)
    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:322)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:132)
    at android.app.ActivityThread.main(ActivityThread.java:4025)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:491)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
    at dalvik.system.NativeStart.main(Native Method)

    Anybody know how to solve this?

  10. Hi Gregor,

    I must say, its an awesome post. I was trying to search for an easy to follow steps tutorial for integrating Facebook in my PhoneGap app. After following the instructions in this tutorial, I was finally able to have facebook into my App.

    I am currently trying to provide a feature to post on user’s wall using my app. I am successfully able to retrieve the acces_token, and see other alerts like the ‘authorized name’ & ‘like’ as somebody posted a code snippet in one of the above comments.

    Following is my code:

    window.plugins.facebook.authorize(appId ,function(res){

    /*alert(res.name); // the authorized users name
    window.plugins.facebook.request(“me/likes” ,function(res){
    alert(res.data[0].name); // the name of the first “liked” item
    });
    */
    window.plugins.facebook.request(‘me/feed?access_token=’ + access_token +’&message=’ + ‘Test_message_Message_frm_PhoneGap_App.’ ,function(res){
    console.log(“My_Phonegap_app: inside success method.”);
    });
    });

    I am not too sure where am I doing something wrong, but the Logcat shows the access_token passed in the final URL invoked as ‘undefined’

    Following is a part of my logcat output:

    08-02 14:49:14.349: DEBUG/Facebook-WebView(6548): Webview loading URL: https://www.facebook.com/dialog/oauth?display=touch&scope=publish_stream%2Coffline_access&client_id=my_Client_ID_XXX&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess&access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY
    08-02 14:49:14.349: DEBUG/Facebook-WebView(6548): Webview loading URL: https://www.facebook.com/dialog/oauth?display=touch&scope=publish_stream%2Coffline_access&client_id=my_Client_ID_XXX&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess&access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY
    08-02 14:49:14.429: DEBUG/PhoneGapLog(6548): file:///android_asset/www/index.html: Line 45 : Mahendra: Token obtained in else block = my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY
    08-02 14:49:14.429: DEBUG/PhoneGapLog(6548): file:///android_asset/www/index.html: Line 45 : Mahendra: Token obtained in else block = my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY
    08-02 14:49:14.879: DEBUG/Facebook-WebView(6548): Webview loading URL: https://www.facebook.com/connect/uiserver.php?app_id=my_Client_ID_XXX&method=permissions.request&display=touch&next=fbconnect%3A%2F%2Fsuccess&type=user_agent&fbconnect=1&perms=publish_stream%2Coffline_access
    08-02 14:49:14.889: DEBUG/Facebook-WebView(6548): Redirect URL: https://www.facebook.com/connect/uiserver.php?app_id=my_Client_ID_XXX&method=permissions.request&display=touch&next=fbconnect%3A%2F%2Fsuccess&type=user_agent&fbconnect=1&perms=publish_stream%2Coffline_access
    08-02 14:49:14.879: DEBUG/Facebook-WebView(6548): Webview loading URL: https://www.facebook.com/connect/uiserver.php?app_id=my_Client_ID_XXX&method=permissions.request&display=touch&next=fbconnect%3A%2F%2Fsuccess&type=user_agent&fbconnect=1&perms=publish_stream%2Coffline_access
    08-02 14:49:14.889: DEBUG/Facebook-WebView(6548): Redirect URL: https://www.facebook.com/connect/uiserver.php?app_id=my_Client_ID_XXX&method=permissions.request&display=touch&next=fbconnect%3A%2F%2Fsuccess&type=user_agent&fbconnect=1&perms=publish_stream%2Coffline_access
    08-02 14:49:15.439: DEBUG/Facebook-WebView(6548): Redirect URL: fbconnect://success#access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&expires_in=0&code=AQCdrxe3txjcHVp0Z772kTsXyKMbvI0fdId1qCWzucN9s0BvpLKD07k6ZeIdcI6z7EbT53fZYknRfEzTsx2tSSK4Vro3EUDgw0kEe2_HIM6T-vU4Y4a1Fm-okiSynAto6lzGhKb8a8xJobEFTKLVBzJOlTrW9THPeVwC1tENM6RSk1QttBRG0XZh0TfmUBBSBJk
    08-02 14:49:15.439: DEBUG/Facebook-authorize(6548): Login Success! access_token=my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY expires=0
    08-02 14:49:15.439: DEBUG/Facebook-WebView(6548): Redirect URL: fbconnect://success#access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&expires_in=0&code=AQCdrxe3txjcHVp0Z772kTsXyKMbvI0fdId1qCWzucN9s0BvpLKD07k6ZeIdcI6z7EbT53fZYknRfEzTsx2tSSK4Vro3EUDgw0kEe2_HIM6T-vU4Y4a1Fm-okiSynAto6lzGhKb8a8xJobEFTKLVBzJOlTrW9THPeVwC1tENM6RSk1QttBRG0XZh0TfmUBBSBJk
    08-02 14:49:15.439: DEBUG/Facebook-authorize(6548): Login Success! access_token=my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY expires=0
    08-02 14:49:15.469: DEBUG/PhoneGapLog(6548): Bundle[{access_token=my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY, expires_in=0, code=AQCdrxe3txjcHVp0Z772kTsXyKMbvI0fdId1qCWzucN9s0BvpLKD07k6ZeIdcI6z7EbT53fZYknRfEzTsx2tSSK4Vro3EUDgw0kEe2_HIM6T-vU4Y4a1Fm-okiSynAto6lzGhKb8a8xJobEFTKLVBzJOlTrW9THPeVwC1tENM6RSk1QttBRG0XZh0TfmUBBSBJk}]
    08-02 14:49:15.469: DEBUG/PhoneGapLog(6548): onActivityResult FacebookAuth
    08-02 14:49:15.469: DEBUG/Facebook-Util(6548): GET URL: https://graph.facebook.com/me?access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&format=json
    08-02 14:49:15.469: DEBUG/PhoneGapLog(6548): Bundle[{access_token=my_Client_ID_XXX|5c632b3f7d762f918fa9303e.3-1050969452|5OWIXgGYga1OnQSQJRLQU1JeieY, expires_in=0, code=AQCdrxe3txjcHVp0Z772kTsXyKMbvI0fdId1qCWzucN9s0BvpLKD07k6ZeIdcI6z7EbT53fZYknRfEzTsx2tSSK4Vro3EUDgw0kEe2_HIM6T-vU4Y4a1Fm-okiSynAto6lzGhKb8a8xJobEFTKLVBzJOlTrW9THPeVwC1tENM6RSk1QttBRG0XZh0TfmUBBSBJk}]
    08-02 14:49:15.469: DEBUG/PhoneGapLog(6548): onActivityResult FacebookAuth
    08-02 14:49:15.469: DEBUG/Facebook-Util(6548): GET URL: https://graph.facebook.com/me?access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&format=json
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.499: ERROR/webcoreglue(6548): The real object has been deleted
    08-02 14:49:16.519: WARN/InputManagerService(1153): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45249588
    08-02 14:49:16.519: WARN/InputManagerService(1153): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45249588
    08-02 14:49:16.559: INFO/System.out(6548): execute: request
    08-02 14:49:16.559: DEBUG/PhoneGapLog(6548): onActivityResult FacebookAuth
    08-02 14:49:16.559: DEBUG/Facebook-Util(6548): GET URL: https://graph.facebook.com/me/feed?access_token=undefined&message=Test_message_Message_frm_PhoneGap_App.?access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&format=json
    08-02 14:49:16.559: INFO/System.out(6548): execute: request
    08-02 14:49:16.559: DEBUG/PhoneGapLog(6548): onActivityResult FacebookAuth
    08-02 14:49:16.559: DEBUG/Facebook-Util(6548): GET URL: https://graph.facebook.com/me/feed?access_token=undefined&message=Test_message_Message_frm_PhoneGap_App.?access_token=my_Client_ID_XXX%7C5c632b3f7d762f918fa9303e.3-1050969452%7C5OWIXgGYga1OnQSQJRLQU1JeieY&format=json
    08-02 14:49:17.009: WARN/Facebook-Example(6548): Facebook Error: Invalid OAuth access token.
    08-02 14:49:17.009: WARN/Facebook-Example(6548): Facebook Error: Invalid OAuth access token.

    Do you have any idea how can I solve this?

    Thanks in advance.

  11. Mahendra liya says:

    Hi,

    I solved my previous error and I’m now stuck with the new one. I am getting the following error:


    08-02 17:19:13.368: DEBUG/PhoneGapLog(9097): file:///android_asset/www/phonegap.js: Line 514 : Error in success callback: FacebookAuth5 = TypeError: Result of expression 'PhoneGap.callbacks[callbackId].success' [[object Object]] is not a function.

    Can you please suggest me where could be I wrong / how can I solve this?

    Do you have a working solution with any server-side backend to post message on Facebook wall?

    Thanks in advance.

    • The error looks like you didn’t pass a function, but a JS Object to the callback. Please check your invocations if you really pass a function to the request.

      Having the full token, the server side is easy to do – if you need further support, please let me know.

  12. newToPhonegap says:

    Hi,

    Thanks for the useful post. I’m new to phonegap and JS. After downloading the Facebook plugin I have moved the java files to the src folder and so I now have src/com/facebook/android/*.java, src/com/hipsnip/plugins/facebook/FacebookAuth.java. I also moved facebook.js to assets/www. Now, I’m trying to write my first very simple application containing a button which when click will detect whether the user is logged-on to Facebook and will just display the user’s name and one of the likes.

    When I tried the application on my phone, I click the button but nothing happens. Obviously something is wrong. The code is below:

    PhoneGap-Facebook

    Login

    $(‘#login’).bind(‘click’, function() {
    window.plugins.facebook.authorize(12345 ,function(res){

    // we have a token, save it (user has authenticated before)
    if(res.token !== undefined){
    alert(res.name);

    window.plugins.facebook.request(“me/likes” ,function(res){
    alert(res.data[0].name); // the name of the first ‘liked’ item
    });
    }

    // we have to call authorize
    else {

    window.plugins.facebook.getAccess(function(res) {

    // we got a token (user has authenticated in that moment)
    if(res.token !== undefined) {
    alert(res.name);
    }
    });
    }

    });
    });

    It could be a JS problem or lack of understanding of the plugin. Thanks for your help.

    • Please check if the facebook plugin is enabled in your project (you could look if window.plugins.facebook is defined).
      Does the facebook auth window pop up when you tap the button? Just to make sure, please insert an alert into your click handler, too.

      • Simon says:

        Hey! Okay, so this reply is pretty much what I’m looking for. I know that my plugin isn’t installed properly because i’m getting as an error:

        TypeError: Result of expression ‘window.plugins.facebook’ [undefined] is not an object.

        But I could not for the life of me figure out how to correctly site the plugin in the plugins.xml file. What I have at the moment is:

        but that doesn’t really work. Any hints?

        Thanks so much in advance!

  13. Libby says:

    Thanks for this! Very useful. I’ve got it mostly working. A question: any reason you add permissions manually (“publish_stream”) in FacebookAuth.java and not call .setPermissions() from javascript instead?

    I plan to try setPermissions() myself, but as nothing seems simple with FB, it may take a day or so to fully test/verify!

    • Actually, setPermissions() was not part of the code at the time of writing this blog entry.
      Thanks for pointing this out, I will have a look at it!

  14. Vishal says:

    I am unable to add the plugin getting the same error

  15. Anvesh says:

    Hi all
    am struggling to post on FB wall could anyone suggest me to post a message on wall….

    Thanks in advance..

  16. NikolasTesla says:

    I found the answer in [url=http://www.google.co.uk]google[/url], remove the topic pls.

  17. VK says:

    HI
    I am currently trying to add feature to post on user’s wall using my android app.i was able to retrieve the acces_token succesfully,i used ajax post method for posting the message on the wall
    $.ajax({
    type: ‘POST’,
    url: “https://graph.facebook.com/me/feed”,
    data: {
    message: text,
    picture: image,
    link: url,
    access_token: token,
    format: “json”
    },
    success: function (response) {
    if (!response || response.error) {
    alert(“Couldn’t Publish Data”);
    } else {
    alert(“Message successfully posted to your wall”+response.id);
    }
    },

    dataType: “jsonp”,
    });

    Iam getting alert “Message successfully posted to your wall”, but particular post is not posted in the facebook wall. response.id is returning as undefined,and response variable is showing as [object,object] in success function

    success: function (response)

    can u please help me in solving the issue

  18. Pingback: Homepage

  19. jim says:

    Hi i have stucked in the step in which we are copying the source java and javascripts into the res folder..when i build the project i am having error in facebookAuth.java and facebook.java..

    Please do help..

  20. jim says:

    Hi i am new to phonegap..after adding the facebook plugin ..when i am trying to run the application
    I am facing an error ehich states that “05-18 14:47:53.066: D/CordovaLog(312): file:///android_asset/www/cordova-1.6.1.js: Line 908 : Error: Status=2 Message=Class not found”

    “TypeError: Result of expression ‘window.plugins.facebook’ [undefined] is not an object.”

    Please do help.

  21. Pingback: My Homepage

  22. oriol says:

    hi! I want to used to connect my aplication but I want to used Sencha. Can I used this code? Is compatible with sencha?

    Sorry for my english