Jan 3, 2012

Google Analytics ME v2.0: Unique visitors

Hi, all

Today, I would like to announce that Google Analytics ME v2.0 has been released. This new version comes with some good news and important changes. See them below:

- Identification of unique visitors.
- Better visitor's features identification.
- Small code refactoring.
- Android support deprecated.

Identification of unique visitors

Now GAN ME identifies properly who is a new visitor or not. This way, your visitors report is 100% accurate about the number of new and old visitors.

Better visitor's features identification

More visitor's features are being collected by GAN ME. For instance, now the app's name, version, screen size and number of colors are being collected.

Small code refactoring

To implement some of the new features and fix some of the bugs, some code changes were required, which may cause some compilation errors for your app. But it is not a big deal from developer's view. Actually, most developers will just have to fix the call to Tracker.getInstance(), which now requires to pass the MIDlet instance as well as the GAN app Id.

Android support deprecated

From this version on, we decided to deprecate the Android support. It turns out that there is already an official GAN API for Android, built by Google. So, we strongly recommend you to use that one in your Android app. It is very good!

I hope everybody enjoy this new version. Let me know your feedback.

To download the API, click here! By the way, inside the package there is a sample app for reference.

See you in the next post...

Dec 6, 2011

Multiple HTTP Headers: No cookie for you

Hi, all

As you may know, HTTP Cookies are mostly used to track sessions between a client and a server. The flow is pretty simple: you access a server and it returns a piece of information (a cookie), which the client stores, in order to send back in every subsequent request. Based on this cookie, the server identifies the client.

Unfortunately, this session management must be handled by the developer, since HttpConnection does not do that automatically. This is achieved in a very simple way and a few lines of code. If do not know how to do it, please learn now here.

According to the example at Nokia's page, session management using a single cookie is very easy. How about two? It should be easy as well. Instead of only one, now you have to store two and send them back.

In a project that I am currently working on, there are two cookies to manage the session. As I said above, it is very easy, right? It should be. I am porting a code from Nokia S60 5th Edition series to S40 6th Edition. This session management works like a charm, but it fails on S40. Any guess? No? Read the post's title again. The answer is:

Series 40 platform devices up to Series 40 6th Edition and Series 40 5th Edition, Feature Pack 1 Lite, and S60 devices prior to S60 3rd Edition, Feature Pack 1 does not support multiple HTTP header. It means that two cookie cannot be handled, because only one is available. Nice, hah?

Long story short, we had to implement a workaround in our server for S40 version, where only one cookie is used for session management. As a consequence of it, this version accesses a no scalable server, since the second cookie was used for load balancer.

W.O.R.A does not work so well on mobile devices.

See you in the next post...

Oct 6, 2011

Twitter API ME 1.8: Now with OAuth support

Hi, all

It's been a long time since my last post, but besides being a little bit busy, I also took a vacation, enjoying a trip to US, to visit some old friends. Great trip, by the way. But now, let's get back to work!

One thing that kept me busy during this time was the implementation of Twitter API ME 1.8. This new version is very special, because it comes with full support to OAuth. Since Twitter changed its Application Permission Model, requiring apps to use OAuth to have access to user's direct messages, Twitter API ME developers were not longer able to access DMs from their apps. Before v1.8, only xAuth was supported.

Other great thing about OAuth is that developers will no longer need to request xAuth permission to Twitter for their apps keys, in order to start working with the API. Since OAuth flow is more secure, Twitter trusts promptly any registered app, because there is no way for apps to get access to user's password. So, no more you have to wait days or until your app is done, so Twitter decides to grant you permission.

It is also important to point out, OAuth is available for all platforms supported: Java ME, Android and RIM.

Besides OAuth, Twitter API ME 1.8 comes with other news:

- Possibility to configure additional connection parameters for RIM platform.
- Improved RIM connection string solving the issue of when the devices is subscribed to BIS.
- Geo-located Trend search based on Yahoo! Where On Earth ID.
- Bug fixes and replacement of some deprecated Twitter API's resources.

I am really glad to have one more version of this successful project released. In addition, I would also like to thank everybody that contributed with the project, reporting bugs and requesting new features through our Express Support.

I strongly recommend you to migrate to v1.8 right away. So, download it now from here. I also prepared some sample apps to help developers to understand how to integrate OAuth into their apps. Just click here and have fun.

See you in the next post...

Jun 20, 2011

Facebook API ME for Android

Hi, all

Continuing the announcements on Facebook API ME, yesterday, I released Facebook API ME v1.0 for Android. This version uses WebView component from Android API to display the authentication page. As I explained in this tutorial, to use the API for other platforms, you just need to work with the respective wrapper class for the target platform. Regarding Android, you will have to use WebViewAuthDialogWrapper.

...
WebView webView = ...;

AuthDialogWrapper pageWrapper = 
    new WebViewAuthDialogWrapper(webView);
pageWrapper.setAppId("App Id goes here");
pageWrapper.setAppSecret("App Secret goes here");
pageWrapper.setRedirectUri("Redirect Uri goes here");
pageWrapper.setPermissions(new String[] {Permission.OFFLINE_ACCESS, Permission.PUBLISH_STREAM});
pageWrapper.addAuthenticationListener(this);
pageWrapper.login();
...

Besides the release package, there is also a sample app demonstrating how to implement the authentication process for this platform. Here it goes the download link.

I hope you guys enjoy it.

See you in the next post...

Jun 18, 2011

Facebook API ME for Blackberry

Hi, all

This afternoon, I released Facebook API ME v1.0 for Blackberry. This version uses BrowserField component from RIM API to display the authentication page. As I explained in this tutorial, to use the API for other platforms, you just need to work with the respective wrapper class for the target platform. Regarding Blackberry, you will have to use BrowserFieldAuthDialogWrapper.

...
BrowserField browserField = ...;

AuthDialogWrapper pageWrapper = 
    new BrowserFieldAuthDialogWrapper(browserField);
pageWrapper.setAppId("App Id goes here");
pageWrapper.setAppSecret("App Secret goes here");
pageWrapper.setRedirectUri("Redirect Uri goes here");
pageWrapper.setPermissions(new String[] {Permission.OFFLINE_ACCESS, Permission.PUBLISH_STREAM});
pageWrapper.addAuthenticationListener(this);
pageWrapper.login();
...

Besides the release package, there is also a sample app demonstrating how to implement the authentication process for this platform. Here it goes the download link.

I hope you guys enjoy it.

See you in the next post...

Jun 10, 2011

Twitter API ME v1.7 and TwAPIme for Android App v1.0 (open source)

Hi, all

Today, I am proud to announce that Twitter API ME v1.7 was finally released. This new version comes with a bunch of new functionalities, improvements and bug fixes. A special fact in this release is that all new functionalities implemented were requested by developers. All of them through our Express Support. So, thank you very much to those developers and their respective companies that contributed to this project.

As I said, this version comes with a great number of news. Check them out:

- Reply tweet
- Timeline of favorite tweets
- Favorite/unfavorite tweet
- User search
- User lookup
- Get friends and followers (full objects, not just id)
- Get friendship details between two users
- New attributes in MetadataSet class
- Bug fixes related to authentication using e-mail address instead of username

As you can see, you will have a lot of work to integrate those new functions into your app.

This version also comes with some remarks:

- From this version on the release's jar file is no longer preverified for Java ME and RIM platforms. It is not necessary, because you will do that when you build your application.

- You can now obfuscate your app with Twitter API ME's jar file without adding any rule to your obfuscator. No class is instantiated using reflection any more.

- HTTP Basic Authentication support was completely removed from source code.

Besides all those great news, there is one more thing (Apple like Tongue): TwAPIme for Android app. This an open source Twitter Android client app totally developed using Twitter API ME v1.7.

I expected to publish this app on Android Market at the same time v1.7 was released, but unfortunately, for time reason, it was not possible yet. Any way, you guys may already check out this good app. I believe it will be worthy for all developers. Find below some features available in this app:

- View Home, Mentions, DM and List timeline
- Post Tweet
- Send DM
- Reply and comment tweet
- Favorite/unfavorite tweet
- Retweet
- View user profile
- View user's lists
- View List's members
- Follow/unfollow user
- Block/unblock user
- Users search
- Report spammer

However, it comes with an important remark that must observed by everybody: Terms of Use

This source code is FREE ONLY for NON-commercial purposes. Actually, you can change it, add new features, fix bugs, etc. However, if you intend to release it as an app of yours, be aware it MUST be 100% FREE, besides making clear it is powered by Twitter API ME project and providing a link to website's project.

I recommend everybody to read the READ-ME.txt file contained in the release package of Twitter API ME and TwAPIme for Android.

So, here it goes the links to download the releases:

Twitter API ME v1.7
http://kenai.com/projects/twitterapime/downloads/directory/1.7

TwAPIme for Android v1.0
http://kenai.com/projects/twitterapime/downloads/directory/TwAPIme

So, I hope everybody enjoys all the news.

See you in the next post...

Jun 5, 2011

Facebook API ME 1.0: Tutorial

Hi, all

As I announced yesterday on Twitter, the first release of Facebook API ME is now available for download. Besides the release package, there is also a sample app, demonstrating how to implement the authentication process.

For while, only the version for eSWT is released. So, if your target device supports eSWT, you will be able to use this package in your Java ME app right away. I am also working on other versions targeted to Blackberry, LWUIT and Android. All of them are now under test phase. I hope to release them very soon. On the other hand, if you cant't wait, check out the source code from the project's repository. You need to add yourself to the project as an Observer member to be able to check out.

Let's start the tutorial!

Registering an App

You need to register an app on Facebook's Developer page. The process is pretty simple and straightforward. The goal of this registration is to obtain some keys that are required by authentication process: App Id, App Secret and Redirect Uri. This process is very similar to Twitter's app registration process.

Once you have the keys, let get to the API itself.

Browser Component

In your app, you need to display Facebook's Login page, so your user can enter his credentials and then grant access to your app. This process is implemented by the API. You just need to provide a browser component instance and then the API takes care of the rest. Considering the eSWT version, you need to provide an instance of Browser class.

Wrapper Class

Once the browser instance is created, you have to wrap it with an instance of AuthDialogWrapper class. This class is responsible for managing the authentication and delegates the events to your app. Considering the eSWT version, you have to instantiate the BrowserAuthDialogWrapper subclass.

Setting Up the Keys

The wrapper object must be set up, so it can handle the authentication process properly for you app. There are some "set" methods that can be used to inform your App Id, App Secret and Redirect Uri. If you prefer, you can enter the keys in the constructor.

...
Browser browser = new Browser(browserComp, SWT.TOP);


AuthDialogWrapper pageWrapper = new BrowserAuthDialogWrapper(browser);
pageWrapper.setAppId("App Id goes here");
pageWrapper.setAppSecret("App Secret goes here");
pageWrapper.setRedirectUri("Redirect Uri goes here");
...

Permissions

Most services provided by Facebook API requires explicit authorization by user. So, during the authentication process you must inform which permissions the services that you intend to work with, must be granted by user.

...
pageWrapper.setPermissions(new String[] {Permission.OFFLINE_ACCESS, Permission.PUBLISH_STREAM});
...

This code snippet says the app will request permission to perform authorized requests on behalf of the user at any time (OFFLINE_ACCESS) and publish content to a user's feed at any time PUBLISH_STREAM. For the full list of permissions provided by Facebook API, click here.

Authentication Events

In order to know if the user granted or denied permission to the app, you need to register a listener of the type AuthenticationListener. This interface has three methods:

- onAuthorize(String token)
- onAccessDenied(String message)
- onFail(String error, String message)

onAuthorize() means the user has granted permission to the app along with the Access Token. Keep this token, since you will use it to sign all your requests to Facebook API. This token works to identify your app. So, from this point on, you can dismiss the login page and start publishing links, comments, etc.

onAccessDenied() means the user has denied access to his Facebook account. It does not mean the user can change his mind later and then authorize your app.

onFail() means that something went wrong during the authentication process. Just try again!

...
pageWrapper.addAuthenticationListener(this);
...


public void onAuthorize(String token) {
    System.out.println("onAuthorize: " + token);
}


public void onAccessDenied(String message) {
    System.out.println("access_denied: " + message);
}


public void onFail(String error, String message) {
    System.out.println("error: " + error + " message: " + message);
}
...

Displaying Login Page

The Facebook's Login page will just be requested and displayed, as soon as the method login() be called.

...
pageWrapper.login();
...

Dispatching Requests

The API also provides a helper class, called Dispatcher, responsible for dispatching the requests, synchronously or asynchronously, to Facebook API. Each Dispatcher instance must be associated to an access token, so all requests dispatched be signed automatically.

...
Dispatcher dispatcher = Dispatcher.getInstance("Access Token goes here");
...

Dispatcher Events

When you work with asynchronous requests, it is recommended to register a listener in order to know whether they were successfully processed. This listener is defined by DispatcherListener interface. This interface has two methods:

- onComplete(Request request, Response response)
- onFail(Request request, Throwable error)

onComplete() means the request was processed successfully and returns the result (response).

onFail() means the request failed, returning the cause.

...
dispatcher.addDispatcherListener(this);
...


public void onComplete(Request request, Response response) {
    ...
}


public void onFail(Request request, Throwable error) {
    ...
}
...

Posting on User's Wall

To publish a text on user's wall is pretty simple. Just instantiate an object of Status class, informing the text in the constructor. The other constructor allows you to post a text on a friend's wall.

...
Status status = new Status("Text goes here");
dispatcher.dispatch(status); //synchronously


//or dispatcher.addToQueue(status); //asynchronously
...


Status status = new Status("Text goes here", "Friend's Id goes here");
dispatcher.dispatch(status);
...

Sharing Link


To share a link is as easy as posting on wall. Just instantiate an object of Link class, informing the URL in the constructor. The other constructor allows you to define how the link will be displayed.

...
Link link = new Link("Link's URL goes here");
dispatcher.dispatch(link);
...
Link link = new Link("Link'URL goes here", "Link's Picture Uri goes here", "Link's Name goes here", "Link's Caption goes here", "Link's Description goes here", "Link's Message goes here", "Friend's Id goes here");
dispatcher.dispatch(link);
...

Retrieving Friends List

To retrieve the user's friends list just instantiate an object of Friends class. This request returns an instance of Friends.Response, which is Enumeration.

...
Friends friends = new Friends();
Friends.Response friendsEnum = (Friends.Response) dispatcher.dispatch(friends);


while (friendsEnum.hasMoreElements()) {
    Friends.Response friend = (Friends.Response)friendsEnum.nextElement();
    String friendId = friend.getId();
    String friendName = friend.getName();
    ...
}
...

Profile Picture

To retrieve a friend's profile picture, create an instance of Picture class, informing the friend's Id in the constructor. This request returns an instance of Picture.Response.

...
Picture picture = new Picture("Friend's Id goes here");
Picture.Response pictureResp = (Picture.Response)dispatcher.dispatch(picture);
byte[] imageBytes = pictureResp.getData();
...

Revoking Authorization

Just in case an user decides to remove your app's authorization to access his Facebook account. For that, use the request defined by RevokeAuthorization class, informing the access token in the constructor. Once this request is processed, the access token is expired and you app will no longer be able to access the user's account. To access it again, the entire authentication process must be redone.

...
RevokeAuthorization revoke = new RevokeAuthorization("Access Token goes here");
dispatcher.dispatch(revoke);
...

Log out

The wrapper class AuthDialogWrapper has a method called logout(). Call this method in order to remove any cookie or logged user's data left by Facebook's Login page in our browser component. It is recommend to call this method when the user removes the app's authorization.

It is important to point out that all items presented here are valid for all versions of Facebook API ME. It does matter if you are working on Blackberry, LWUIT or Android. The steps are all the same, except at item 3, regarding the type of subclass. Each platform has its own subclass of AuthDialogWrapper.

So, I hope this tutorial has been useful for you guys, as well as the API itself.

As soon as the release of the other platforms are released, I will let everybody knwos.

See you in the next post...

News

Loading...