Showing posts with label twitter. Show all posts
Showing posts with label twitter. Show all posts

Feb 14, 2011

Twitter API ME 1.6: Finally

Hi all,

I would like to announce that Twitter API ME 1.6 has just been released. The main features present in this version are:
  • Retweets to me timeline
  • Retweets by me timeline
  • Tweets from list timeline
  • List management (e.g. create, update, memberships, subscriptions, etc)
  • Special character (*) in password bug fix
To download the new version, click here.

See you in the next post...

Oct 31, 2010

Twitter API ME 1.5

Hi all,

Quick post just to announce that Twitter API ME 1.5 has just been released.

In this new version, the following new features are available:
  • List of pending friends/followers request
  • Report spam
  • Retweets of me timeline
  • Trend Topics search
  • Tweet's entities
  • Retrieval of access token from UserAccountManager class
For further information on this new release, access www.twitterapime.com

See you in the next post...

Oct 8, 2010

xAuth lib: OAuth made easy

Hi all,

Nowadays, important sites on web are growing their presence in mobile space. As usual, a quick way to go in this direction is releasing mobile versions of their sites. On the other hand, they also use to provide means so third-party sites and apps can access their content and services. For instance, many sites (or platforms), e.g., Google, Yahoo, Facebook, Twitter, etc, provide APIs, so that developer can build their products that rely on content from them.

To start accessing any content or service from one of those sites, you first need to authenticate with it. The site needs to recognize you so it can open their doors for you. The type of authentication may vary depending on each site. It is commom to encounter with Http Basic Auth, which is very easy to work with. However, most services are shifting to OAuth. A more secure auth mechanism that also avoids third-party sites have access to user's credentials. Recently, Twitter turned off its Http Basic Auth, to support only OAuth. Some sites still work with both, but it is matter of time so they keep only OAuth.

Due to some aspects of OAuth, its pure implementation is not feasible for desktop and mobile apps. This is related to a spec flow that demands your app to be redirected forth/back to/from a login page. It is kind of complicated to accomplish that in a mobile app, for instance. To avoid this step, they created xAuth, which is same as OAuth, but the login page flow.

An OAuth request is quite more complicated to perform, since it requires a signature for the request, which uses some hash algoritms and encoders. To now more about it, click here.

In my Twitter API ME project, I had to implement it, since as I previously said, Twitter turned off Http Basic Auth. However, my xAuth implementation was designed to be reused by other apps and frameworks. So, if you are looking for xAuth lib for your app, you are at the right place. So, to start it up, download the latest version of Twitter API ME at www.twitterapime.com.

Below I will put some code snippets that demonstrate how to get authenticated to Twitter and then post a tweet. After downloading the API, you will need to obtain your app's OAuth keys: consumer key and secret. They will be used to produce that signature I mentioned ealier. Those keys are provided by the site you want to connect with, after a quick subscription. Let's show some code:

01. HttpRequest req = new HttpRequest("https://api.twitter.com/oauth/access_token");
02. req.setMethod(HttpConnection.POST);

 
03. XAuthSigner signer = new XAuthSigner("", "");
04. signer.signForAccessToken(req, "", "");

05. try {
06.     HttpResponse resp = req.send();
07.     if (resp.getCode() == HttpConnection.HTTP_OK) {
08.        Token accessToken = Token.parse(resp.getBodyContent());

09.        req.close();

10.        req = new HttpRequest("http://api.twitter.com/1/statuses/update.xml");
11.        req.setMethod(HttpConnection.POST);
12.        req.setBodyParameter("status", "");
13.        req.setSigner(signer, accessToken);

14.        resp = req.send();
15.     }
16. } catch (IOException e) {
17.     e.printStackTrace();
18. } finally {
19.     try {
20.         req.close();
21.     } catch (IOException e) {}
22. }

Basically what we do is to sign each request, using XAuthSigner class, as we see in the lines 4 and 13. As soon as you get authenticated, you will obtain your access token (line 8). From this point on, every request will be signed using your keys and token. This token, in turn, can be stored for further use. It avoids requesting user's credentials next time and skip auth step.

I recommend before trying to access any site using xAuth, that read its documentation first, so you can see whether they require an additional procedure to work with xAuth. I am mentioned that, because Twitter, for instance, demands us to send an e-mail to them requesting privileges to use xAuth in our apps. Otherwise, it will not work. So be aware of that.

So, that's all guys! I hope it be useful for all of you.

See you in the next post...

Jun 14, 2010

Twitter API ME 1.3: xAuth support

Hi all,

I am here to announce that Twitter API ME 1.3 has been released just a few moments ago. This new version is mainly focused on xAuth support implementation. As you may know, Twitter API is shutting down the Http Basic Auth support on June 30th, 2010. This way, we had to run to get it done, otherwise, the API would work from this date. But we made it and now it is time to download to keep the things running.

Other important new feature is the fully support to UTF-8 characters. Now you can tweet in Russian, Japanese, Chinese, etc.

By the way, now you can also develop proprietary applications with Twitter API ME, because the binaries are now under LGPL v3.0 license. Cool, huh?

To download the new version, click here.

See you guys in the next post...

Apr 29, 2010

New Version of Twitter API ME: A bit earlier.

Hi all,

I am pleased to announce that Twitter API ME 1.2 has just came out of the oven, with some great new stuffs and some challenges in sight. This new version took a bit more than a month to be developed. As we had previously advanced, we had planned to release it just on June. However, we decided to advance it, since Kenai.com will be under migration process from next Friday (April 30th), for an undetermined period. The website will be still up, but it will be completely read-only. This way, we could not upload the new version after April 30th.

For those who do not know, this migration process of Kenai.com has to do with the deal between Oracle and Sun Microsystems. But do not worry! Even after April 30th, you can download the new version. :)

Now let's outline what is new in version 1.2:
  • Retweet
  • Direct message posting and retrieval
  • Friendship management, i.e., follow/unfollow and block/unblock
  • Access to Public, Home, User and Mentions timelines
  • Rate limit status access for Search API
A lot of stuff, huh? For instance, now you can send private messages to your friends, follow someone (or block if you do not like him/her), see all tweets from your friends (same as you see at Twitter's home) and the ones that mention you, etc. With version 1.2, you have a complete set of features that allow you to implement a full-featured Twitter application.

As the previous ones, this version was expressively tested and new test cases were also implemented for all new features to guarantee the quality. Now we have over 100 test cases, covering 91% of the code.

Regarding documentation, all new features are well documented in the source code (Javadoc) and there is also some code snippets in our Wiki page.

As I said in the beginning we already have a challenge in sight. Currently, Twitter API ME uses Http Basic Authentication method to authenticate to Twitter API. However, Twitter API team has defined a deadline (June 30th) to deactivate this support. They are requesting that every application move to OAuth, which they state to be more suitable for them, because it is more secure for the users. No problem, let's do it. Because of that, we have to rush to get it done ASAP.

I believe that's all. I hope you guys enjoy this new version and bring me comments, suggestions, ideas so we can continue improving this API, OK?

Ah!!! I almost forgot. Here it goes the download link. :)

See you in the nest post...

Apr 22, 2010

Twitter API ME 1.2: Almost done!

Hi all,

I decided to stop by to tell you guys that the new version of Twitter API ME, 1.2., is almost concluded. After the development and unit testing, we are now performing a final code review before release. This new version comes with great new features, e.g., timelines, direct messages, retweet, etc.

The release is scheduled for the beginning of June. So, stay tuned! To follow the development, check us on Twitter, @twiterapime.

See you in the next post...

Jan 5, 2010

Twitter API ME: New Year, New Version.

Hi all,

First of all, I would like to wish everybody a happy New Year. A 2010 full of health and achievements for all of us.

Besides the greetings, today I am here to announce the launch of Twitter API ME 1.1. Finally I have concluded this version. It took more time that I had planned, because I had to do some changes on certain parts of the API, in order to accommodate the new features. So, the version is already available in the website www.twitterapime.com in the section "Downloads\releases".

The new features from this new version are:
  • Tweet Posting (main one)
  • User authentication
  • Rate Limit Status access
  • Android 1.1 support for all the features
  • Some bug fixes and optimizations
For sure, the main new feature is Tweet Posting. Without posting tweets, Twitter does not make much sense, isn't it? So that's why we focused on providing this feature ASAP. See bellow how easy is to post a tweet from Twitter API ME 1.1:

Credential c = new Credential("username", "password");
UserAccountManager uam = UserAccountManager.getInstance(c);
if (uam.verifyCredential()) {
 TweetER ter = TweetER.getInstance(uam);
 Tweet t = ter.post(new Tweet("status message"));
}


That's all!!! Easy, isn't it?

Another important news from version 1.1 is the full support on Android 1.1. Now, you can also work with Twitter API ME on your Android applications.

To ensure the quality of the API, some unit tests have been implemented to ensure that no bug comes up after any change. Currently, we have 91 test cases covering 69% of the code. The objective for the next version is to increase this percentage as much as possible.

I hope to publish a new version of Sparrow application ASAP, so you guys can have a reference application.

So, give this new version a shot and download it now.

See you in the next post...

Nov 19, 2009

Now on Twitter too: Follow us!!!

Hi all,

Little break on MIDP 3.0 topic.

Now you can also follow the updates on our blog and much more, following J2ME Group on Twitter. The username is j2megroup. Quite easy, isnt't it? :-) Start following now.

See you in the next post...

Nov 5, 2009

Twitter API ME: Sample App

Hi all,

Have you already downloaded Twitter API ME 1.0? Yes? Great!!! To help still more, I just developed a sample app, Sparrow, so you guys can have a better understanding on how this API works. For while, it only provides a functionality for searching tweets. For instance, you enter some filters and then the application shows the results.

I attempted to use as many features as possible available on Twitter API ME 1.0 in this app. The idea is to show all you can do with the API. As new features come available, I will update the app, implementing a respective functionality.

To download the app, click here. In the zip file, you will find the source, binaries and lib.

I hope it helps you a lot.

See you in the next post...

p.s: Now, you can also access the project's page on www.twitterapime.com.

Oct 29, 2009

Twitter API ME: Quick Tutorial

Hi all,

Such as I advanced in Twitter API ME's announcement post, here it goes some code snippets to demonstrate how to use this API. In fact, I will consider this post as a first tutorial on Twitter API ME that will help you to get started. First of all, I will show you how to create a simple query, submit it to Twitter Search API and then present the result. So you will not see much detail in this quick tutorial. Actually, I am thinking of dedicating more posts to explain each class in detail. But for now, let's just see how it works.

Twitter API ME, such as Twitter API, is splitted into two main components: Search and REST APIs. Twitter API ME 1.0 just supports Search API services. So, for now, you will work with the package com.twitterapime.search only. This package contains all the classes that are responsible for submitting a query to Twitter and then getting the result. These are the main classes:
  • Query
  • QueryComposer
  • SearchDevice
  • Tweet
Query class wraps a string that represents a query, which is submitted to Twitter Search API. This query is in URL format. To compose a query, the developer can use the QueryComposer class. This class provides methods for most types of filters/parameters supported by Twitter Search API. For instance, QueryComposer.from(String) is used to create a query to search for all tweets submitted by a certain user; QueryComposer.contain(String), search for tweets that contain a given word, and so on.

It is also possible to create a query with more than one parameter. In this case, you can concatenate two queries, by calling the method QueryComposer.append(Query, Query). It will return a new query object with both queries concatenated.

SearchDevice class is the entry point to Twitter Search API. This class provides the methods to submit a query to Twitter and retrieve the search's result. Its use is very straighforward: create a query and pass to SearchDevice.searchTweets(Query) method. The return of this method is an array of Tweet objects. Tweet class represents a tweet: a Twitter's message.

To retrieve the tweet's info (e.g. message, author, publish date, etc.), just use one of its "get" methods (e.g. Tweet.getString(String)), passing one of the attributes defined by MetadataSet interface. The Tweet's attributes are represented by the contants that start with TWEET prefix, e.g., MetadataSet.TWEET_CONTENT.

Now let's show some code. This example demonstrates how to search for all the tweets sent by a given user (e.g. me) and that contains the word "F1" (we will get a lot of results :-)):

...
SearchDevice sd = SearchDevice.getInstance();
Query q1 = QueryComposer.from("ernandesmjr");
Query q2 = QueryComposer.contain("F1");
Query q3 = QueryComposer.append(q1, q2);
Tweet[] result = sd.searchTweets(q3);
for (int i = 0; i < 0; i++) {
 list.append(result[i].getString(MetadataSet.TWEET_CONTENT), null);
}
...

Let's search for tweets that references or mentions a certain person. In additional, we will request to Twitter Search API to return up to 5 tweets:

...
SearchDevice sd = SearchDevice.getInstance();
Query q1 = QueryComposer.reference("ernandesmjr");
Query q2 = QueryComposer.resultCount(5);
Query q3 = QueryComposer.append(q1, q2);
Tweet[] result = sd.searchTweets(q3);
for (int i = 0; i < 0; i++) {
 System.out.println(result[i].getString(MetadataSet.TWEET_CONTENT));
 System.out.println(result[i].getString(MetadataSet.TWEET_PUBLISH_DATE));
}
...

It is easy, isn't it? The rest, for while, is just a matter of discovering the others methods available in thoses classes. But the main use is what is described in these code snippets. More details you can check on javadoc.

See you in the nest post...

Twitter API ME: The announcement.

Hi all,

In the last few weeks, as soon as I became a Twitter's user, I had an idea to create an API so that we could develop applications to get access to Twitter's information. This work started on studying the API from Twitter API website, in order to see how the things work. I got surprised how easy is to access this service - very straightforward. In a nutshell, the API is based on accessing a URL and passing some parameters and get the response. For some API's services, authentication is required, but it is not a big deal to manage.

Basically, Twitter API is splitted into two parts: Search and REST API. Search API is responsible for providing a search mechanism of tweets (a Twitter message), by submitting a query with some parameters (filters), e.g., search for all tweets submitted by a given user or that contains a given word/phrase. The REST API, in turn, provides means to submit tweets to Twitter.

So after studying the API, I started to design and code an API so that we could have access to Twitter API from our mobile devices. The idea is to have an structure such as Twitter API, with those two main components: one for search and other for submitting content.

This API was designed using just plain old Java language, so that we could have an API to run on many platforms. In other words, this API intends to run on any Java platform (e.g. Java ME, Android, Java SE, etc.). It is possible, because the interface for the developers is pure Java, however, the concrete classes are platform dependent.

Due to my short free time, until this moment, I have implemented the Search API services and for Java ME platform only. However, the API is totally functional and ready to be used. I am already planning to implement REST API and a support for Android. It is expected for the next release. In the meanwhile, download and try it. It is free! It is upon GPL-2.0 license.

You guys can download the binaries, source code and documentation from projects's website, which is hosted on Kenai project website. For while, the SVN repository is not available. I am still working on somethings, but soon you guys will be able to check out the code directly to your IDE, OK? In additional, you guys can also report bugs/improvements on our issue tracking tool (JIRA).

I hope you guys like this project. It is getting cool! In the next posts, I will post some code snippets on how to use the API.

See you in the next post...