Over a million developers have joined DZone.

Facebook OAUTH Solutions - Adding Backend to Nokia S40 Apps

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

Doing Facbook OAuth on Nokia S40 and J2ME devices is biggest challenge while creating the social apps for this platform becuase of unavailibility of the facebook J2ME SDK and inapp browser limitation of J2ME devices. App42 platform J2ME SDK provides easiest and quickest way to do seamless Facbook OAuth on J2ME devices with out going in the complexity ofunderlying protocol.

Here are the few easy steps to do the FB OAuth for these devices.

Canvas URL : https://api.shephertz.com/cloud/1.0/social/facebook/saveFeaturePhoneFBToken?
Secure Canvas URL : https://apps.shephertz.com/socialkeys.php?
  • Also, make sure that sandbox mode is off for your app.
  • Register with App42 platform if not already registered and create an app for you.
  • Download the latest J2ME SDK from our public Git repo
  • Unzip the downloaded file and put App42_J2ME-x.x.x.jar in your project class path.
  • Now you are ready to do Facebook OAuth with just few lines of code as shown below
ServiceAPI  sp = new ServiceAPI("YOUR_API_KEY","YOUR_SECRET_KEY");
String fbAppId = "YOUR_FB_APPID";
String fbAppSecret = "YOUR_FB_APP_SECRET";
String accessToken = null;
String [] appPermissions = new String [] {"publish_stream","friends_online_presence"};
String code = sp.buildSocialService().doFBOAuthAndGetToken(midlet, fbAppId, appPermissions);
//The Above call will open user login OAuth page in browser and will wait till user authorizes the app.
accessToken = sp.buildSocialService().getAccessTokenFromCode(code, fbAppId, fbAppSecret);
System.out.println( "  Token : " + accessToken);
Social socialObj = sp.buildSocialService().getFacebookFriendsFromAccessToken(accessToken);
Vector friendList = socialObj.getFriendList();
//This will return Facebook friends of user whose access token was passed.
  • In above snippet doFBOAuthAndGetToken method will do all the trick, it will open FB user OAuth page and will wait till user authorizes the app.
  • Once user does the authorization, user’s acccesscode is redirected to our server and being further received by your app and being returned by this method.
  • Once you have got the acceess code you can make another call getAccessTokenFromCode to get the access token of that user.
  • Whole story ends once you got the access token with you. Now you can call getFacebookFriendsFromAccessToken on our SDK or can directly use facebook graph API for fetching other information of user.

You can use other App42 backend services like GamingStorageFile StorageMessagingGeo Spatial,Custom Code to make user engaging social app with writing any backend for J2ME/S40 devices. Start making beautiful Apps with App42 Cloud API S40 SDK. Here is the Sample Code to get you started.

Article Resource: http://blogs.shephertz.com 

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}