Giter Site home page Giter Site logo

anqizhang1 / twitter4j Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twitter4j/twitter4j

1.0 0.0 0.0 12.13 MB

Twitter4J is an open-source Java library for the Twitter API.

Home Page: http://twitter4j.org/

License: Apache License 2.0

Shell 1.26% Java 97.84% Batchfile 0.89%

twitter4j's Introduction

Twitter4J

#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

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

Stargazers

 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.