java-twitter


A Java wrapper around the Twitter API

Java Twitter

A Java wrapper around the Twitter API

Author: DeWitt Clinton <dewitt@unto.net>

Introduction

This library provides a pure Java interface for the Twitter API.

Twitter (http://twitter.com) provides a service that allows people to connect via the web, IM, and SMS. Twitter exposes a web services API (http://twitter.com/help/api) and this library is intended to make it even easier for java programmers to use.

Using

Download the latest source or binary version of java-twitter from:

http://code.google.com/p/java-twitter/downloads/list

Documentation

Read the online javadocs at:

http://java-twitter.googlecode.com/svn/site/apidocs/index.html

Begin at:

http://java-twitter.googlecode.com/svn/site/apidocs/net/unto/twitter/Api.html

View the Maven project site at:

http://java-twitter.googlecode.com/svn/site/index.html

Examples

Connect to Twitter and print out the latest public messages:

``` import net.unto.twitter.Api; import net.unto.twitter.TwitterProtos.Status;

Api api = Api.builder().build(); for (Status status : api.publicTimeline().build().get()) { System.out.println(String.format("%s wrote '%s'", status.getUser().getName(), status.getText())); } ```

Send a Twitter message:

``` import net.unto.twitter.Api;

Api api = Api.builder().username("username").password("password").build(); api.updateStatus("This is a test message.").build().post(); ```

Maven

Add the following to your pom.xml:

<repositories> ... <repository> <id>java-twitter-repository</id> <url>http://java-twitter.googlecode.com/svn/repository/</url> <name>java-twitter maven repository</name> </repository> ... </repositories>

And

<dependencies> ... <dependency> <groupId>net.unto.twitter</groupId> <artifactId>java-twitter</artifactId> <version>0.9-SNAPSHOT</version> </dependency> ... <dependencies>

Runtime Dependencies

The java-twitter library requires that the following runtime dependencies are installed in the CLASSPATH:

The precise dependencies used to build the published jars can be found on the autogenerated Maven site:

http://java-twitter.googlecode.com/svn/site/dependencies.html

Building

Using Maven

Install Java 1.6 or greater:

http://java.sun.com/javase/6/

Install Maven:

http://maven.apache.org/

Maven will automatically fetch the runtime and test dependencies:

Run the following:

$ mvn package

The JAR file will be generated as:

target/twitter-0.9.jar

Protocol Buffers

A pre-generated .java file representing the Twitter protocol buffers is checked in as:

src/main/java/net/unto/twitter/TwitterProtos.java

If you would like to compile your own, the source file is checked in as:

src/main/proto/twitter.proto

To generate the corresponding .java file, download and build the protocol buffer compiler from:

http://code.google.com/p/protobuf/

And run:

protoc --proto_path=src/main/proto/ --java_out=src/main/java/ src/main/proto/.proto

Javadocs

Generate the javadocs for the project with:

$ mvn javadoc:javadoc

The generated javadocs can be found at:

target/site/apidocs/index.html

More Information

Please visit http://groups.google.com/group/java-twitter for more discussion.

License

``` Copyright 2009 DeWitt Clinton All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```

Project Information

Labels:
java twitter api