jReddit


Source link: https://github.com/jReddit/jReddit

jReddit

What is jReddit?

jReddit is a wrapper for the Reddit API written in Java. Project started by Omer Elnour. Taken over for further development and maintenance by Karan Goel, Andrei Sfat, and Simon Kassing.

How to use jReddit?

We are currently in the transitional phase between cookie-based authentication and OAuth2. The previous version of jReddit (1.0.3), which uses the former, will no longer be supported by reddit beginning August. The latter is supported by the latest version of jReddit (1.0.4).

Latest version: 1.0.4

The latest version (1.0.4) can only be included by forking or directly copying source. When the build is stable, we will distribute it via Maven (as done with previous versions).

Old version (deprecated): 1.0.3

At the moment, jReddit 1.0.3 can be included in your project using:

Maven
<dependency>

<groupId>com.github.jreddit</groupId>

<artifactId>jreddit</artifactId>

<version>1.0.3</version> </dependency> 
Gradle
dependencies {

  compile group: 'com.github.jreddit', name: 'jreddit', version: '1.0.3' 
}
 

What can it do?

jReddit supports the creation of clients and bots using the Java language. It communicates using the reddit api, and all its actions are limited by the functionality offered there. It can for example authenticate apps using OAuth2, retrieve subreddits, submissions and comments, and perform various actions such as flairing, hiding and saving.

Examples

Examples can be found in Examples package. A full example Gradle (Android) project can be found in the Gradle example folder. To give you an impression, here is a code snippet for a simple example:

Connect a user

// Information about the app String userAgent = "jReddit: Reddit API Wrapper for Java"; String clientID = "JKJF3592jUIisfjNbZQ"; String redirectURI = "https://www.example.com/auth";  // Reddit application RedditApp redditApp = new RedditInstalledApp(clientID, redirectURI);
 RedditOAuthAgent agent = new RedditOAuthAgent(userAgent, redditApp);

  RedditClient client = new RedditHttpClient(userAgent, HttpClientBuilder.create().build());
  // Create a application-only token (will be valid for 1 hour) RedditToken token = agent.tokenAppOnly(false);
  // Create parser for request SubmissionsListingParser parser = new SubmissionsListingParser();
  // Create the request SubmissionsOfSubredditRequest request = (SubmissionsOfSubredditRequest) new SubmissionsOfSubredditRequest("programming", SubmissionSort.HOT).setLimit(100);
  // Perform and parse request, and store parsed result List<Submission> submissions = parser.parse(client.get(token, request));
  // Now print out the result (don't care about formatting) System.out.println(submissions);

Note: please see the reddit OAuth2 information page for more information on acquiring a client identifier, secret, and redirect URI.

What's next for jReddit?

The plan is to implement every feature documented here. To see which methods have been implemented, and which have not, see this file.

How to contribute?

It is recommend to start with forking and reading through the source code, in oder to understand the general structure and standards used. Then check the implemented_methods.md file to see which methods have not yet been implemented. Choose the ones you'd like to contribute to. When you implement a new request, make sure it is fully covered by testing (via JUnit), and that all other tests pass as well. Thorough documentation of your addition is appreciated.

Send in a pull request, including test, and it will be gladly merged to improve the library! :-)

Dependencies

  1. JSON-simple

  2. Apache HttpComponents

  3. SLF4J

  4. Apache OLTU

Resources

A Gradle plugin witch automatically packs texture for a libgdx game, using libgdx texture packer. Before packing, the plugin can do some actions on the resources provided, such as:

  • Resize images for variants
  • Generate 1 pixel 9-patches automatically
  • Convert SVG to PNG images

Gradle tasks for easy integration with ImageMagick.

The code brings up an easy way of using recyclerView, with the new recycler adapters. It also contains a BaseRecyclerFragment and a RecyclerStandalone that removes a lot of boiler plate for fragments that contains either grids or lists. It also offers out of the box a DividerItemDecoration that handles the drawing of the divider in the recycler view. As well selectors for the items in your lists are handled.

RecyclerView-FlexibleDivider - Android library providing simple way to control divider items of RecyclerView.

JDeferred is a Java Deferred/Promise library similar to JQuery's Deferred Object.

android-deferred-object is a chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes