Code Monkey home page Code Monkey logo

jreddit's Introduction

jReddit

Build Status

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 maintainence by Karan Goel.

What can it do?

jReddit can login with a user, retrieve user information, submit new links, and vote/comment on submissions, send and receive messages and notifications among other things.

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?

Personally, I would suggest reading through the source code 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. After you write the method (and maybe commit it?), write a test to see if it works fine and as expected. Then make sure other tests are working too and your code does not break anty other method.

Send in a pull request with the test and I'll be happy to merge! :-)

Dependencies

  1. JSON-simple

  2. Apache HttpComponents

  3. Apache Commons IO

Examples

Connect a user

// Initialize REST Client
RestClient restClient = new HttpRestClient();
restClient.setUserAgent("bot/1.0 by name");

// Connect the user 
User user = new User(restClient, "username", "password");
try {
	user.connect();
} catch (Exception e) {
	e.printStackTrace();
}

Retrieve top 100 submissions of /r/programming

// Handle to Submissions, which offers the basic API submission functionality
Submissions subms = new Submissions(restClient, user);

// Retrieve submissions of a submission
List<Submission> submissionsSubreddit = subms.ofSubreddit("programming", SubmissionSort.TOP, -1, 100, null, null, true);

Submit a link and self post

// Handle to SubmitActions, which offers the basic API functionality to submit comments and posts
SubmitActions submitActions = new SubmitActions(restClient, user);

// Submit a link
submitActions.submitLink(
        "Oracle V Google judge is a programmer!",
        "http://www.i-programmer.info/news/193-android/4224-oracle-v-google-judge-is-a-programmer.html",
        "programming");
        
// Submit a self post
submitActions.submitSelfPost("What's the difference between a duck?",
        "One of its legs are both the same!", "funny");

Send a message to another user

import com.github.jreddit.message.Messages;
import com.github.jreddit.user.User;

/**
 * @author Karan Goel
 */
public class ComposeTest {

    public static void main(String[] args) {
        User user = null;
        String recipientUsername = "other_user";
        try {
            user = new User("username", "password"); // Add your username and password
            user.connect();
        } catch (Exception exception) {
            exception.printStackTrace();
        }

        new Messages().compose(user, recipientUsername, "this is the title", "the message", "", "");
    }
}

jreddit's People

Contributors

beresfordt avatar snkas avatar naduse avatar raulrene avatar sfat avatar evinugur avatar jonnykry avatar jasonsimpson avatar aliakhtar avatar sudocurse avatar jamesgold23 avatar mrcorporate avatar vafada avatar mtt88 avatar mattbdean avatar hainna01 avatar rvanbaarle avatar flightofstairs avatar corgibyte avatar trentrand avatar c-ameron avatar

Watchers

James Cloos 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.