BlackBerry Webworks Facebook Post

Facebook integration with an Webworks app, can be a really tricky matter. If you ever tried this you’ve noticed that the Facebook JavaScript SDK, don’t work in the widget and also that the Facebook BlackBerry SDK, is intended for JDE project and also don’t work on a Webworks project.

The best thing that I’ve found in the web that partially solved this, was to use ChildBrowser-plugin-for-BlackBerry, that maybe it used to work, but since some new modifications in the Facebook API, it doesn’t work anymore…

Actually with the ChildBrowser-plugin-for-BlackBerry, I was able to login and retrieve the token using the Torch 9800 simulator, but it just didn’t work for the Bold( device or simulator), so I needed to dive more deeply into it.

I’ve notice this plugin used a BrowserField to connect to Facebook and that it make no sense that it worked on the Torch simulator and not on Bold.

On the Bold device, when I tried to login, it just refreshed the page and didn’t login adding some Security notice.

Since the login worked on any other desktop browser, I’ve opened a sniffer and looked at how was the communication between the browser and Facebook.

Then I’ve also debugged the webworks app and noticed that the only difference between them were that the BlackBerry app was sending an x-wap-profile and maybe this was the reason why Facebook was rejecting the communication.

To be able to set those headers, I needed to create my own ProtocolController, and by doing this I could trick Facebook to think that actually it was a Desktop browser trying to connect. I’ve also had to implement the ability to store and send cookies, and after doing that I was able to connect to Facebook and actually retrieve the token.

Since I used the ChildBrowser-plugin-for-BlackBerry, I think that it’s only fair that I also share my progress, and so you can download it from here BlackBerry-Webworks-Facebook-Post

 

Best regards,

Daniel Botelho

  • Giacomo Preciado

    How do I use the plugin, any help? I’ve downloaded the project on gitHub but i’m not sure how to use it

  • Anonymous

    Hi! 
    1) First you need to install the Javascript extension. Just download the file https://github.com/dbotelho/BlackBerry-Webworks-Facebook-Post/blob/master/bin/FacebookPost.jar and add it to your “ext” folder in your Webworks project;
    2. Then go to your “config.xml” file and add this line:

    Now you should be able to access the “com.dbotelho.facebook” namespace!

  • Giacomo Preciado

    I’ve already done that and the blackberry simulator shows me error “Javascript alert: ReferenceError: cant find variable com” any suggestions?

  • Anonymous

    Hi! It seems that your not including the javascript extension correctly. Please take a look at the sample project that I’ve uploaded: https://github.com/dbotelho/BlackBerry-Webworks-Facebook-Post/tree/master/samples/facebookpost

  • Anonymous

    This extension looks very promising but I’m having trouble getting the example to work (with the Facebookpost.jar). When I click to post to facebook, it is strangely redirecting me to this website when I test on a device. However, it is working fine on the simulator for BB OS 7. Any suggestions?

  • Anonymous

    Hmm… Please remove the line 14 from the index.html file (https://github.com/dbotelho/BlackBerry-Webworks-Facebook-Post/blob/master/samples/facebookpost/index.html#L14) and try again on the device. Maybe your tapping in that line instead of the button?

  • Anonymous

    True! I removed the ‘focus’ navigation and was able to click the button directly. Why doesn’t focus work properly?? Any tips on that?

    Thanks for this amazing extension!

  • Anonymous

    How do I make the facebook login page appear in english instead of spanish?

  • Mirra

    Hi, Im doing the same, and have the same error, cant find variable: com. I downloaded the sample project and I have put my app id and secret, but still the same error, Im runing the sample in the virtual machine playbook. Pls Help!!!!

  • Anonymous

    Hi, that error happens when the JS Ext is not correctly enabled on the application.

    I see that you are trying to use this extension on the playbook, but I never tried it there and I don’t know if it’s even compatible with it.
    I believe that you should ask in the http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/bd-p/browser_dev if that is possible and if so they can point you out how to solve this.

  • Candra_klikocean

    I have problem….

    after I put my app_id and app_secret and I run in ripple there is an error like ReferenceError: com is not defined

  • Anonymous

    Have you included the “com.dbotelho.facebook” extension in the “config.xml” file? Please look at https://github.com/dbotelho/BlackBerry-Webworks-Facebook-Post/blob/master/samples/facebookpost/config.xml

  • Candra_klikocean

    yes i have…but not running in ripple….

  • Candra_klikocean

    I have a problem again….
    my prev issue has fixed….

    I create new apps and same code just different app_id and UI…but after login in fb appeared alert like “object is not an extension object” and can’t post status…

  • kalu

    I have the same error: com is not defined, but i included the extension in the config.xml…what can i do?

  • kalu

    Hi, how did you the sample to work?….I have this error: com is not defined, but i included the extension in the config.xml