Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 3
Registered: ‎10-21-2009
My Device: Not Specified

api to generate session key for facebook connect

i m making a BB app in which i need to post a mssg to walls of users facebook friends, for this i need to have a session key. can anyone tell me the api to generate it or any other method to this? i have api key, secret key, user id and password. please help me....

Developer
Posts: 55
Registered: ‎03-26-2009
My Device: Not Specified

Re: api to generate session key for facebook connect

+1 to the OP. I would like to know this too.

New Developer
Posts: 27
Registered: ‎11-03-2009
My Device: 8320
My Carrier: XL

Re: api to generate session key for facebook connect

There is no direct way to generate the session key however you can use Facebook Connect Authentication method applicable for Desktop Application (yes, it does work for Mobile Application as well).

 

Assuming you are using JDE 4.5 above the following steps summarise the workflow:

 

  1. Using Browser Field, as described in the "Authorization and Authentication for Desktop Applications" [1] do a POST to the Facebook Mobile Web login URL of http://m.facebook.com/login.php instead of http://www.facebook.com/login.php and make sure you have all the arguments correct including the calculated signature.
  2. Once the User successfully logged in and authorises your application, capture the browser's URL in order to obtain the auth_token.
  3. Do a POST to the REST server (http://www.facebook.com/restserver.php) to obtain the session key and secret (auth.getSession).
  4. Store the session key and secret to a persistence store and wholla! You are in business.

I am actually in the process of creating a LoginScreen and FacebookFacade objects incorporating the first three steps described above.

 

References:

 

[1] http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Desktop_Applicati...

Developer
Posts: 85
Registered: ‎12-05-2008
My Device: Blackberry 8900 Javelin

Re: api to generate session key for facebook connect

@ebaskoro: I am interested to hear how you get on with that. I had terrible issues with pre 5.0 OS and browser handling of the Facebook Javascript/cookie handling. I could view the login screen but hitting the login button always reported "You must log in to view this" or similar. It may be related to the amount of javascript, or the problems with the Javascript "unknown" property, or the security employed by Facebook via cookies, etc.

 

With OS 5.0 i could log in fine but when i tried prompting for permissions (in the same session and with the same BrowserField) i kept getting more "You must log in to view this page". I could not find a way of logging in and prompting for permissions seamlessly. It seemed the user details were lost between the login page and the permissions page. I tried forwarding manually (via requestContent()) and also via the login callback url. I also tried the standard (www.) and mobile (m.) login pages with no success.

 

I had issues with some user accounts being forwarded to normal HTTP content and other facebook accounts being forwarded to TLS://...:443 pages - i still have no idea why Facebook changed the protocol and am pretty sure i set permissions for the various Facebook accounts to be the same.

 

Getting a session works as does checking for permissions - the REST API works well - but that cursed Facebook login page and the not-quite-decent Java browser API put a dampner on the whole affair!

 

I hope you are able to integrate properly with the Facebook API and i am happy to be schooled in the Java API should that be the case.

 

New Developer
Posts: 27
Registered: ‎11-03-2009
My Device: 8320
My Carrier: XL

Re: api to generate session key for facebook connect

@robin: I am actually using JDE 4.5 and haven't got the opportunity to test it on higher version.

 

I have posted the codes here http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html

New Developer
Posts: 8
Registered: ‎07-10-2008
My Device: Not Specified

Re: api to generate session key for facebook connect

[ Edited ]

HI Baskoro,

 

 

I am really impressed ,that you have done for Blackberry. I have only one question- How can we get auth_token?

 

Please let me know, I tried for that but not getting any sucess.

 

Thanks & Regards

-Abhijeet

Developer
Posts: 34
Registered: ‎09-24-2009
My Device: Not Specified

Re: api to generate session key for facebook connect


ebaskoro wrote:

@robin: I am actually using JDE 4.5 and haven't got the opportunity to test it on higher version.

 

I have posted the codes here http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html


 

Hi ebaskoro,

 

Thanks for posting the code. I tried your code but I am also facing the same issue (Not able to get the auth_token) . I am able to see the login page. Then after clicking on 'connect, button the browser is redireceted to the following URL. 

 

http://m.facebook.com/developers/login_error.php?app_id=xxxxxxxxxxxxxxxxxxxxx&type=external

 

Do I need to have a proxy server &  specify the Canvas URL on Facebook site.

Please tell me what are the other modifications required.

 

  

Thanks,

Ravi

Developer
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: api to generate session key for facebook connect

Hi ebaskoro,

                       Good work ebaskoro, i have done authentication by ur code but i cant get extended permissions like publish_stream after authenticate its automatically redirect to the login screen..


i am first calling http://m.facebook.com/login.php? and after when the login is succesful i am calling


http://www.facebook.com/connect/prompt%5Fpermissions.php?api%5Fkey=YOUR%5FAPI%5FKEY&ext%5Fperm=publi......


but the problem is i am again and again getting login windows...iit continues to show me login window eve when i enter my username and password...someone plzz help me out..its very urgent..

 

Pls any one Help me..

 

Thanks,

Packiaraj

Highlighted
Developer
Posts: 46
Registered: ‎06-11-2009
My Device: Bold 2 - Pearl 8120

Re: api to generate session key for facebook connect

Hi  Packiaraj,

 

             Could you solve this, I'm trying to implement the same and I have the same problem.

 

 

Regards,

 

Monica

 

If your issue is resolved, please mark this thread as solved. Click "Accept as solution" on the post that contains the answer to your question.
New Developer
Posts: 27
Registered: ‎11-03-2009
My Device: 8320
My Carrier: XL

Re: api to generate session key for facebook connect

[ Edited ]

@Abhijeet: Have a look at my HOWTO link. In essence, it grabs the returned URL once the user authenticates and grants permission to your app.

 

@Packiaraj: Unfortunately the mobile version of the login page seems to ignore publish_stream and offline_access permission requests. The work around is to request for extended permission as you have been trying to do. The only trick is to combine the login and the extended permission request as follows:

 

data.append("&next=http://www.facebook.com/connect/prompt_permissions.php?api_key=" + facebookFacade.getApplicationKey() + "&display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&fbconnect=true&ext_perm=read_stre...");

 

Remove the req_perms parameter.

 

I will post the updated code shortly on my website.

 

Warm regards,

 

Eki