Skip to content

Twitter RestAPI toy wrapper for Java which is released under the MIT Licence

License

Notifications You must be signed in to change notification settings

rf0321/twi-Java

Repository files navigation

Twi-Java

LICENCE Maintainability Build Status PRs Welcome

Twitter API wrapper for Java

Main API wrapping is implemented by standard library.

Json Decoding is implmented by org.json.

Java Version

This wrapper's current java version is java8

Installation

1.Download Twi-Java.jar

2.Add as Library the jar

Usage

About detail of params that send to api, please check API Reference

Get Instance

 TwiJava twitter = new TwiJava();

Authentication in API keys(Required method)

twitter.authorize("consumerKey","consumerSecretKey","accessToken","accessTokenSecret");

Tweet

twitter.tweet("Hello World");

Delete Tweet

twitter.deleteTweet("your tweet id_str");

Search Tweet

twitter.searchTweet("Hello");

Custom Search Tweet

If you use optional param

  TreeMap<String,String> customSearch = new TreeMap<>();
  customSearch.put("q",ParamEncoder.encode("Hello"));
  // Below is optional params
  customSearch.put("count","25");
  customSearch.put("locale","ja");
  customSearch.put("result_type","popular");
       
  HttpRequest httpRequest = new HttpRequest();
  httpRequest.get(TwitterApiURLs.SEACH_URL,customSearch);

Get User Timeline

twitter.getUserTimeLine(100); 

Get Home Timeline

twitter.getHomeTimeLine(100);

Get User Profile

twitter.getUserProfile("screen_name");

Get Follower List

twitter.getFollowerList();

Custom Get Follower List

 TreeMap<String,String> param = new TreeMap<>();
 param.put("cursor","-1");
 // Below is optional params
 param.put("screen_name","twitter's @id");
 param.put("count","30");

 HttpRequest httpRequest = new HttpRequest();
 httpRequest.get(TwitterApiURLs.FOLLOWERS_URL,param);

Get Friend(Follow user) List

twitter.getFriendList();

Custom Get Friend List

 TreeMap<String,String> param = new TreeMap<>();
 param.put("cursor","-1");
 // Below is optional params
 param.put("screen_name","twitter's @id");
 param.put("count","30");

 HttpRequest httpRequest = new HttpRequest();
 httpRequest.get(TwitterApiURLs.FRIENDS_URL,param);

Twitter time line Json decode(this is optional mini function)

String json = twitter.getHomeTimeLine(50);
JsonDecoder.decodeTimeLine(json);

Implemented urls

POST /1.1/statuses/update.json
POST /1.1/statuses/destroy/:id.json
GET  /1.1/statuses/user_timeline.json
GET  /1.1/statuses/home_timeline.json
GET  /1.1/search/tweets.json
GET  /1.1/users/show.json
GET  /1.1/followers/list.json
GET  /1.1/friend/list.json

Contributing

I welcome it. But if you pullrequest to this repository,you should write description of pullrequest content in English.

LICENCE

MIT License

Copyright (c) [2017] ItinoseSan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Twitter RestAPI toy wrapper for Java which is released under the MIT Licence

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages