Code Monkey home page Code Monkey logo

twitter4j's Introduction

X4J

#Twitter4J is a 100% pure Java library for the Twitter API with no extra dependency.

@t4j_news

Requirements

Java 8 or later

Dependency declaration

Add a dependency declaration to pom.xml, or build.gradle as follows:

Maven Central

Maven

<dependencies>
    <dependency>
        <groupId>org.twitter4j</groupId>
        <artifactId>twitter4j-core</artifactId>
        <version>4.1.2</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    compile 'org.twitter4j:twitter4j-core:4.1.2'
}

Java modularity

requires org.twitter4j;

Getting started

Acquire an instance configured with twitter4j.properties, tweet "Hello Twitter API!".

twitter4j.properties

oauth.consumerKey=[consumer key]
oauth.consumerSecret=[consumer secret]
oauth.accessToken=[access token]
oauth.accessTokenSecret=[access token secret]

Main.java

import org.twitter4j.*;
public class Main {
  public static void main(String... args){
    Twitter twitter = Twitter.getInstance();
    twitter.v1().tweets().updateStatus("Hello Twitter API!");
  }
}

v1() returns TwitterV1 interface which provides various Twitter API V1.1 API resources. tweets() returns TweetsResources.

You can also get a builder object from newBuilder() method to configure the instance with code:

Main.java

import org.twitter4j.*;
public class Main {
  public static void main(String... args){
    var twitter = Twitter.newBuilder()
      .oAuthConsumer("consumer key", "consumer secret")
      .oAuthAccessToken("access token", "access token secret")
      .build();
    twitter.v1().tweets().updateStatus("Hello Twitter API!");
  }
}

License

Apache License Version 2.0

Java CI with Gradle

twitter4j's People

Contributors

yusuke avatar takke avatar lqd avatar mumei avatar dk8996 avatar komiya-atsushi avatar abahgat avatar withgod avatar applepedlar avatar danaja avatar goncalossilva avatar jloomis avatar pompopo avatar moko256 avatar mocel avatar sigpwned avatar thepoofy avatar s17er avatar krallus avatar wg avatar eliasisrael avatar arankin avatar akashnawani avatar ciaranj avatar graysky avatar georgeludwig avatar nivs avatar plaanv avatar mttvll avatar monosite avatar

Stargazers

xda7958 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.