Open earth-tone opened 9 years ago
I will take a look at this as soon as possible. I apologize for any delay as I am just getting back from vacation and am a bit swamped at work. In the meantime, I don't see any tests added for these changes.
On Tue, Aug 4, 2015 at 12:10 PM, earth-tone notifications@github.com wrote:
So, this will likely look like a huge mess. The readme has a detailed explanation and is nicely formatted, so I won't retype it all here, I'll just summarize. When I have more time I may do a more detailed writeup. At the moment I just wanted to get this out there because of Reddit's new Oauth requirement that went into effect August 3rd.
-I've updated Reddit::Client with Oauth support. There is now a get_token(client_id, secret, username, password) function. Tokens last for an hour and refresh automatically if your script runs continually for more than an hour. Instructions on registering a script are included.
-Added get_subreddit_comments function, which get all the comments from a subreddit or multi. Reddit's new API maxes out at 100 results, so another function that only does a basic json request (no API) is planned, to hopefully be able to grab 500 at a time.
-send_message function is still there from the last time
-me() function updated to work with new API
You can view, comment on, or merge this pull request online at:
https://github.com/jsober/Reddit-API/pull/14 Commit Summary
- test
- initial commit; adds get_subreddit_comments support
- initial commit; adds get_subreddit_comments support
- initial commit; adds get_subreddit_comments support
- initial commit
- initial commit
File Changes
- D README https://github.com/jsober/Reddit-API/pull/14/files#diff-0 (57)
- A README.md https://github.com/jsober/Reddit-API/pull/14/files#diff-1 (59)
- M lib/Reddit/Client.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-2 (133)
- M lib/Reddit/Client/Account.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-3 (12)
- M lib/Reddit/Client/Comment.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-4 (16)
- M lib/Reddit/Client/Link.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-5 (6)
- M lib/Reddit/Client/Request.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-6 (37)
- M lib/Reddit/Client/SubReddit.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-7 (6)
- M lib/Reddit/Client/Thing.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-8 (15)
- M lib/Reddit/Client/VotableThing.pm https://github.com/jsober/Reddit-API/pull/14/files#diff-9 (6)
Patch Links:
- https://github.com/jsober/Reddit-API/pull/14.patch
- https://github.com/jsober/Reddit-API/pull/14.diff
— Reply to this email directly or view it on GitHub https://github.com/jsober/Reddit-API/pull/14.
Old programmers don't die; they just parse on...
I've been avoiding unit tests because I've never done them and don't know exactly what should be in them.
I added a file called unit_tests, which has 7 tests of the new functions using Test::Simple. It basically just checks that each one works, it doesn't test all scenarios.
I'm not expecting all of this code to get accepted soon (or ever); I kind of submitted it for completeness and so it wouldn't look like I was developing my own separate version of Reddit::Client or something. I'm not; I'm just adding the functions that I need. With the Oauth change, I had to decide whether to update my Python PRAW bots to work with it, or to move everything to perl and update Reddit::Client to do everything that PRAW does. I opted for the latter. Most of my scripts are in Perl anyway and it's a lot easier for me to write in Perl; the only reason I was using PRAW at all was because it had functions that Reddit::Client didn't.
I'm still very actively working on it. I just now removed the login requirement from send_message() because Oauth no longer needs a traditional login and it was breaking things; your token is what your cookie would have been before.
And literally two days after I wrote the get_subreddit_comments function, Reddit does this: https://www.reddit.com/r/redditdev/comments/3fx3gt/quarantined_content_will_be_unavailable_through/
The API won't return results from "quarantined" subs. The only way to opt in is to visit the sub through Reddit.com and click "yes".
So the only way for a function that gets comments (or fetch_links that gets links) to be content agnostic is to get it right from the json at Reddit.com without hitting the API. That won't be hard, but it will affect a few functions.
So, this will likely look like a huge mess. The readme has a detailed explanation and is nicely formatted, so I won't retype it all here, I'll just summarize. When I have more time I may do a more detailed writeup. At the moment I just wanted to get this out there because of Reddit's new Oauth requirement that went into effect August 3rd.
-I've updated Reddit::Client with Oauth support. There is now a get_token(client_id, secret, username, password) function. Tokens last for an hour and refresh automatically if your script runs continually for more than an hour. Instructions on registering a script are included.
-Added get_subreddit_comments function, which get all the comments from a subreddit or multi. Reddit's new API maxes out at 100 results, so another function that only does a basic json request (no API) is planned, to hopefully be able to grab 500 at a time.
-send_message function is still there from the last time
-me() function updated to work with new API