Giter VIP home page Giter VIP logo

jreddit's Introduction

jReddit

Build Status Maven Central Coverage 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 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

jreddit's People

Contributors

aliakhtar avatar anseriform avatar arocketman avatar beresfordt avatar c-ameron avatar corgibyte avatar dincciftci avatar eduardog3000 avatar evinugur avatar flightofstairs avatar hainna01 avatar immatt avatar jamesgold23 avatar jasonsimpson avatar jonnykry avatar mattbdean avatar mleef avatar mrcorporate avatar mtt88 avatar naduse avatar player1537 avatar raulrene avatar rvanbaarle avatar sfat avatar snkas avatar sudocurse avatar trentrand avatar vafada avatar vitineth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jreddit's Issues

Getting any property from a LinkedList of submissions throws a null pointer exception

If you try to get a property (title, URL, author, etc.) from a submission it throws a NullPointerException. For example:

User user = new User(restClient, "username", "password");
user.connect();

for (Submission submission : new Submissions(restClient).getSubmissions("programming",
            Submissions.Popularity.HOT, Submissions.Page.FRONTPAGE, user)) {
    System.out.println(submission.getTitle());
}

Throws a NullPointerException, citing the line with the getTitle call.
The stack trace cites Submission.java, line 367:

Object object =  restClient.get(urlPath, user.getCookie()).getResponseObject();

The rest client must not be returning the response object correctly. :P

Finalizing the Comment, Submission and Subreddit class variables

The Comment, Submission and Subreddit class all have getters and setters, which makes it appear as if you can set certain to a value and that this will have effect on Reddit (e.g. setNSFW() could be interpreted as 'mark as NSFW').

Isn't it better to finalize all fields, thus preventing this confusion?

SubmitAction comment() returns true when the comment is not posted.

I was making a bot and noticed that SubmitAction comment() returned true even though the comment was not successfully posted due to Reddit's 10 minutes restriction for new users

(One comment every 10 minutes for new users in certain subreddits).

Here's my implementation to reproduce:

public boolean post(RestClient restClient, User user, YoutubeVideo video, Submission s){
    SubmitActions submitAction = new SubmitActions(restClient, user);
    String message = createMessage(video.getName(), video.getAuthor(), video.getViews(), video.getLikes(), video.getDislikes());
    if(submitAction.comment(s.getFullName(), message)){
        return true;
    }
    else{
        System.out.println("There was something wrong");
        return false;
    }
}

Sorting submissions does not work

I just updated one of my bots to the latest version of the code, and I'm having a issue where sorting doesn't work at all. It's only returning the hot submissions, nothing else.

I took a quick look at ApiEndpointUtils.java and noticed that some of the calls to the API was not correct (e.g. On SUBMISSIONS_GET, /r/%s.json?%s should be /r/%s/%s.json). So I tried fixing that, but with no luck.

No Such Field Error

When trying to run an app that includes the jreddit library, a no such field error gets thrown: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

I've posted this on SO, but as there was no response, I'd thought I'd try here.

Thanks.

Subreddit is a Thing

Subreddit does not extend Thing.
User on the other hand does, while it isn't a Reddit Thing (it is uniquely identified by its username, which is used as parameter everywhere instead of a FullName).

HttpRestClient is incompatible with Android

Following the discussion from here: https://www.reddit.com/r/androiddev/comments/2ygmgm/having_trouble_with_apache_httpclient_in_android/

The version of httpclient supplied with Android is older than the one used with jReddit (4.3.3). This causes issues when trying to use jReddit's HttpRestClient on Android due to missing classes that are only present in the newer version of httpclient (such as RequestConfig) and incompatibilities (such as UrlEncodedFormEntity on Android not being able to take a java.nio.charset.Charset).

The issue regarding missing classes can be solved by using this Android port of httpclient 4.3 and excluding the httpclient dependency from jReddit. An example:

compile('com.github.jreddit:jreddit:1.0.2') {
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'

However, this brings to light the second issue. This line from HttpRestClient throws an exception at run time because, in Android, UrlEncodedFormEntity does not have a constructor that matches List<NameValuePair>, CharSet. (It has two constructors: one that takes List<NameValuePair> and one that takes List<NameValuePair>, String.)

java.lang.NoSuchMethodError: org.apache.http.client.entity.UrlEncodedFormEntity.<init>
    at com.github.jreddit.utils.restclient.HttpRestClient.post(HttpRestClient.java:156)

Two possible solutions:

  1. Downgrade httpclient in jReddit to be compatible with Android
  2. Provide a separate artifact specifically for targeting Android that uses httpclient-android and UrlEncodedFormEntityHC4 (and its ilk) for compatibility.

Disclaimer: I have not tested the extent of incompatibilities on Android. It's likely that there are more than just the one described here and other classes will need changed as well.

Post to a live thread.

public String postToLive(String message, String thread) throws IOException {
  String apiParams = "api_type=json&body=" + message+ "&uh=" + user.getModhash();

  Response res = restClient.post(apiParams, "/api/live/" + thread + "/update", user.getCookie());

  return res.getResponseText();
}

Scanner only reads 1024 bytes from stream

commit ff22e67

In Utils.java

public static Object get(String apiParams, URL url, String cookie)
        throws IOException, ParseException {
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    //connection.setDoOutput(true);
    connection.setUseCaches(false);
    connection.setRequestMethod("GET");
    // Don't pass cookie if it is null
    if (cookie != null) {
        connection.setRequestProperty("cookie", "reddit_session=" + cookie);
    }
    connection.setRequestProperty("User-Agent", userAgent);


    // Debugging stuff
    // @author Karan Goel
    InputStream is = null;
    Scanner s = null;
    String response = null;
    try {
        if (connection.getResponseCode() != 200) {
            s = new Scanner(connection.getErrorStream());
        } else {
            is = connection.getInputStream();
            s = new Scanner(is);
        }
        s.useDelimiter("\\Z");
        response = s.next();
        System.out.println("\nResponse: " + response + "\n\n");
        s.close();
    } catch (IOException e2) {
        e2.printStackTrace();
    }
    // Debugging stuff


    JSONParser parser = new JSONParser();
    return parser.parse(response);
}

The Scanner only reads 1024 characters off of the input stream causing the JSON parser to fail. The exception thrown by the parser is "Unexpected token END OF FILE at position 1024."
Java 1.6 Android 4.3

Proposed method name changes

getUserInformation --> getMyInfo

about --> getUserInfo

since the first one gets the info of the currently logged in user and the second gets the info of any arbitrary user

user.connect() Does not work. Always throws Exception.

It doesn't let me use it, always throws an NPE. I get this when running UserTest. I will be looking into it tomorrow if no one else does.

java.lang.NullPointerException
at im.goel.jreddit.user.User.hashCookiePair(User.java:271)
at im.goel.jreddit.user.User.connect(User.java:45)
at UserTest.test(UserTest.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at

java.lang.AssertionError: The user's modhash should never be null, lest no API methods function properly. (Invoke the connect function to remedy this)
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.assertTrue(Assert.java:43)
at org.junit.Assert.assertNotNull(Assert.java:524)

Can't search the getSubmissions() method inside the project

I was going through examples GetPaginatedTopics.java within the examples package. Here it shows there is this getSubmissions() method on the Submissions instance.

But when I peered inside the Submissions class I couldn't find any method by that name. What am I missing here? If this question is very lazy I apologize.

https access and some error handling on failed login

index 88c9761..e619bd9 100755
--- a/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java
+++ b/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java
@@ -8,7 +8,7 @@ package com.github.jreddit.utils;
*/
public class ApiEndpointUtils {

public static final String REDDIT_BASE_API_ENDPOINT = "/api";

~/Documents/git/jReddit: git diff
diff --git a/src/main/java/com/github/jreddit/entity/User.java b/src/main/java/com/github/jreddit/entity/User.java
index 0d53ad5..cf08f5a 100644
--- a/src/main/java/com/github/jreddit/entity/User.java
+++ b/src/main/java/com/github/jreddit/entity/User.java
@@ -100,10 +100,13 @@ public class User {
ArrayList values = new ArrayList();
JSONObject jsonObject = (JSONObject) restClient.post("api_type=json&user=" + username + "&passwd=" + password, String.format(ApiEndpointUtils.USER_LOGIN, username), getCookie()).getResponseObject();

JSONObject valuePair = (JSONObject) ((JSONObject) jsonObject.get("json")).get("data");

  •    values.add(valuePair.get("modhash").toString());
    

- values.add(valuePair.get("cookie").toString());

  •    if(valuePair == null) {
    
  •        JSONObject errors = (JSONObject) ((JSONObject) jsonObject.get("json")).get("errors");
    
  •        throw new RuntimeException(errors.toJSONString());
    
  •    } else {
    
  •        values.add(valuePair.get("modhash").toString());
    
  •        values.add(valuePair.get("cookie").toString());
    
  •    }
     return values;
    
    }

diff --git a/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java b/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java
index 88c9761..e619bd9 100755
--- a/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java
+++ b/src/main/java/com/github/jreddit/utils/ApiEndpointUtils.java
@@ -8,7 +8,7 @@ package com.github.jreddit.utils;
*/
public class ApiEndpointUtils {

public static final String REDDIT_BASE_API_ENDPOINT = "/api";

Create master branch

Currently, the "stable" branch is called "karan". It would more appropriate to have a "master" branch.

Error handling and management

While testing, I was really struggeling with the question 'To what extent should this API be demanding/defensive?'

Currently (in my fork) the Comments/Submissions/Subreddits classes have minimal preconditions for the arguments, with only throwing a IllegalArgumentException if one of the arguments is totally invalid (like a null when retrieval submissions of a subreddit).

But for example you receive a 403 when trying to retrieve submissions, should this result in a null, an empty list of submissions or an exception PermissionDeniedException? And should these be Runtime or Static exceptions? Any thoughts guys? @karan ?

Create proper Exception classes

Following #40, I moved the only custom exception class that currently exists, InvalidCookieException, in a exception package.

I was discussing the other day with @sfat and came to the conclusion that we need at least one "generic" RedditException class, but most probably will need to also provide others. We should discuss here about possible exceptions needed and implement them as it wouldn't take too long.

@karan, @cgza and anyone that has ideas about what exception classes would be needed, please provide some feedback. Thanks!

RetrievalFailedException when parsing with URL

I would like to parse all the recent comments from one (or more) subreddits using an URL:

Comments comments = new Comments(restClient, user);
List<Comment> allComments = comments.parseBreadth("/r/test/comments");

But I am getting this Exception all the time:

Exception in thread "main" com.github.jreddit.exception.RetrievalFailedException: Input/output failed when retrieving from URI path: http://www.reddit.com/r/test/comments
at com.github.jreddit.utils.restclient.HttpRestClient.get(HttpRestClient.java:103)
at com.github.jreddit.retrieval.Comments.parseBreadth(Comments.java:85)
at test.Test.main(Test.java:50)
Java Result: 1

I tried everything to find out what I'm doing wrong, with no success.
I hope I'm not overlooking a dumb mistake.

I get the exact same exception when trying to parse from a user page, or when I try to parse submissions with an URL.
Reading comments from a submission works fine, but is impractical for what I'd like to use them for.

Using this wrapper without logging in

You can call many of the Reddit API methods without ever needing to log in, so it seems a little silly to require a username and password when constructing a User. I have a couple proposals in mind:

  1. Create a no-parameter User constructor. Then, if the user ever wants to call an API method that requires being logged in, allow them to call connect(username, password) OR setUsername(name), setPassword(pw), connect().
  2. Instead of the User being the main interface through which a user interacts, create a Reddit class that does that job. This is because it's weird to interact with the Reddit API through a User class if you are in fact not logged in. A user simply creates a Reddit object and then if he ever wants to call a login-required API method, he can do Reddit.login(name, pw). Possible downside: how to handle multiple users connected at the same time?

Also, it doesn't look like there are currently measures put in place to handle cases where not-logged-in users call methods that require the user to be logged in. One exception being getUserInformation(). Perhaps I am wrong in this but this is how it appears.

Posting comments without a captcha is broken

When posting a comment with no captcha, there is an issue with how the querystring is built, and later parsed, that causes an ArrayIndexOutOfBoundsException.

In Messages.compose, the querystring is constructed and passed to HttpRestClient.post. If there is no captcha, the String will end up looking something like this:

captcha=&iden=&subject=some subject....

In HttpRestClient.convertRequestStringToList, the strings is then tokenized on '&', with each token being tokenized again on '='. The final array produced is then indexed into directly.

This means that, when there is no captcha, the string is tokenized into an array whose first element is "captcha=". When that String is then tokenized on '=', this results in an array of length 1 (the empty string to the right of the '=' is ignored by String.split). So when the code reaches nameValue[1], an exception is thrown, since there is no second element.

Improvement for Comments: bring the replies as a Tree

As stated in #64, currently our system brings the replies to the comments as a JSON string. It would be a nice functionality to have them as a Tree<Comment>, in order to be able to properly parse them and see their dependencies.

However, any other suggestion about how we should represent them is welcomed.

Maven Package Fails

I think this is a similar issue as #80, but I am not getting the same errors as the original poster. I am trying to package the software using maven

mvn package

I am getting these errors: http://pastebin.com/Q7V7dP3r

I can package the software using sbt, if interested here is the build.sbt: http://pastebin.com/Se9RpHiG

I noticed some plugins in the pom.xml but I don't know how those translate into sbt terms. This was my first time using maven.

Here is my java version:
lamez@studio-mint ~/GitHub/jreddit $ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Here is my maven version:
lamez@studio-mint ~/GitHub/jreddit $ mvn --version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-12-generic", arch: "amd64", family: "unix"

NullPointerException in User.comments("username")

Using User.comments with a non-existent user throws a NullPointerException instead of returning null or checking. I believe the method is not checking if the query returns a null with nonsense usernames?

Easy way to get comments page

Currently have to do this:

try {
     Method m = User.class.getDeclaredMethod("submit", String.class, String.class, boolean.class, String.class);
     m.setAccessible(true);
     Object obj = m.invoke(reddit, postTitle, uploadResponse.getLink(), false, subreddit);
     JSONObject jobj = (JSONObject) obj;
     callback.onPostSuccess(((JSONArray) ((JSONArray) ((JSONArray) jobj.get("jquery")).get(16)).get(3)).get(0).toString());
} catch (Exception e) {
     e.printStackTrace();
     callback.onPostFailure();
}

Make jReddit available on Maven central repo

It would help a lot of people to have the possibility to just add jReddit as a new dependency in pom.xml rather than downloading the jar or having to download the sources and making his own jar to add it in his/her project.

I can work on this guy, if that's okay with you @karan

Post not showing up at Reddit

Hi,

We are trying to submit a link to Reddit via the API. However the post is not visible at Reddit. Please see the code below and help us with the issue


public final class GenerousBot {
public static void main(String[] args) throws Exception {
RestClient restClient = new HttpRestClient();
restClient.setUserAgent("Generous-Bot");
User user = new User(restClient, "XXXXX", "XXXXX");
user.connect();
user.submitLink("xxxxx","http://xxxxxxx.com","sports");
}


Comments retrieval

I'm currently implementing the Comment retrieval, but the way Reddit returns the comments is quite perculiar

When you ask to give 300 comments with depth 2, it will select the 300 comments that it finds most fitting. When you ask to given 300 comments with depth 1, it will select the 300 first level comments (as expected).

My proposal: first do a breadth first search, retrieving all comments, and then retrieve for each comment that has children the max amount of comments (500), thus giving approximately all comments in a thread. The comments are then recursively added to a RoseTree (maintaining the order).

Any ideas?

Development workflow

I'm not sure whether this a valid question to be posed in the issues tab, but here goes. I've the project built using the command mvn clean install. Although after doing that I'm not sure what steps I should take if I want to implement an API call.

I'm wondering what the basic workflow is like. So how do I run the project and the examples given here?

Tests run against real reddit

When a test using TestUtils is run it connects to Reddit with the credentials in that class and attempts the action under test against the live site. For test purposes it might be preferable to mock the interaction with Reddit; this will give greater control over what can be tested (eg rate limit exception behaviour could be tested without spamming Reddit)

Proper Wiki?

Hi,

I wanted to go to the Wiki to check for all the Methods since I was unable to understand some of them, but I realized that there is no Wiki. I was wondering if you could build a Wiki to guide users of the Wrapper on how to properly implement it.

Regards,
Michael

com.github.jreddit.utils.restclient missing

I can't use the import com.github.jreddit.utils.restclient as is says it's not there.

my code:

import com.github.jreddit.submissions.Submission;
import com.github.jreddit.submissions.Submissions;
import com.github.jreddit.utils.restclient.PoliteRestClient;
import com.github.jreddit.utils.restclient.RestClient;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.List;

@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {

    @ViewById(R.id.submissinList)
    ListView submissionList;

    @Background
    void load_submissions()
    {
        RestClient restClient = new HttpRestClient();
        restClient.setUserAgent("bot/1.0 by name");

        // 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);

    }
}

Posting Links was not working

Posting a link was not working and I got it to work by changing line 312 in User.java

From
+ (selfPost ? "link":"self" ) + "&uh=" + getModhash(),
To
+ (selfPost ? "self":"link" ) + "&uh=" + getModhash(),

Add Android example

Adding a simple android example so people will be able to grab and modify accordingly to their need, since there quite a lot of people trying yo use jreddit in their android app.

Please release 1.0.1-SNAPSHOT to maven

Any IDE that uses maven makes it extremely easy to include dependencies. Right now we have to build your project and include the JAR file and all its dependencies by hand.

The version currently released to your maven repository is the very old 1.0.0 release, please upload the current version.

Missing classes

I'm trying to use jReddit on my project, but when I add it via gradle into Intellij Idea there's a lot of classes missing. For example, the whole folders "comment" and "exception" are missing. The same thing when I download the jar from the maven repository. Am I doing something wrong?

Error while importing maven project into Eclipse

I get this error while importing the maven project into eclipse:

Failure to transfer org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0 from/to central (http://repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom

Am I missing something trivial? Searching the error did not present any relevant results.

IDE Version: 3.8.1
Eclipse Plugin: m2e
Platform: Ubuntu 14.04

Proposed move from JSONSimple

Hi,

Based on the stuff I started for using a collaborator to aid mocking and testing reddit interactions in this branch:

https://github.com/beresfordt/jReddit/tree/httpClientCollaborator

And the annoyances of dealing with JSONSimple I started experimenting with using https://github.com/FasterXML/jackson-core and making better use of the apache HttpClient to manage cookies

I have committed a preliminary updated version of User and UserTest which are both simpler in terms of usage and in terms of testing. I have also added (temporarily) an integration test so you can see real reddit interactions with the newer RedditServices

The jackson/HttpClient cookie management branch is here:
https://github.com/beresfordt/jReddit/tree/jackson

The test showing RedditServices interacting with reddit is here:
https://github.com/beresfordt/jReddit/blob/jackson/src/test/java/com/github/jreddit/utils/restclient/RedditServicesIntegrationTest.java

Let me know what you think, or if you have any questions

Why does User constructor accept a RestClient?

I think every User instance should create and maintain its own RestClient. An outside user shouldn't be responsible for passing one in; that's an implementation detail.

I also want to note that the examples in the README don't pass in a RestClient, but as it currently stands the code requires it.

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.