Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oauth Support #14

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Oauth Support #14

wants to merge 17 commits into from

Conversation

earth-tone
Copy link

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

@sysread
Copy link
Owner

sysread commented Aug 5, 2015

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:

#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

Patch Links:


Reply to this email directly or view it on GitHub
#14.

Old programmers don't die; they just parse on...

@earth-tone
Copy link
Author

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.

@earth-tone
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants