Skip to content

Commit

Permalink
adjusted auth URLs, incremented SSL version (remove 403 errors), and …
Browse files Browse the repository at this point in the history
…modified auth req object
  • Loading branch information
jcleblanc committed Nov 6, 2015
1 parent ee40f3d commit cf62ce1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 70 deletions.
6 changes: 3 additions & 3 deletions config.php
Expand Up @@ -3,13 +3,13 @@ class redditConfig{
//standard, oauth token fetch, and api request endpoints
static $ENDPOINT_STANDARD = 'http://www.reddit.com';
static $ENDPOINT_OAUTH = 'https://oauth.reddit.com';
static $ENDPOINT_OAUTH_AUTHORIZE = 'https://ssl.reddit.com/api/v1/authorize';
static $ENDPOINT_OAUTH_TOKEN = 'https://ssl.reddit.com/api/v1/access_token';
static $ENDPOINT_OAUTH_AUTHORIZE = 'https://www.reddit.com/api/v1/authorize';
static $ENDPOINT_OAUTH_TOKEN = 'https://www.reddit.com/api/v1/access_token';
static $ENDPOINT_OAUTH_REDIRECT = 'http://localhost/reddit/test.php';

//access token configuration from https://ssl.reddit.com/prefs/apps
static $CLIENT_ID = 'YOUR CLIENT ID';
static $CLIENT_SECRET = 'YOUR CLIENT SECRET';
static $CLIENT_SECRET = 'YOUR SECRET';

//access token request scopes
//full list at http://www.reddit.com/dev/api/oauth
Expand Down
70 changes: 3 additions & 67 deletions reddit.php
Expand Up @@ -44,10 +44,9 @@ public function init_oauth(){
$code = $_GET["code"];

//construct POST object for access token fetch request
$postvals = sprintf("code=%s&redirect_uri=%s&grant_type=authorization_code&client_id=%s",
$postvals = sprintf("code=%s&redirect_uri=%s&grant_type=authorization_code",
$code,
redditConfig::$ENDPOINT_OAUTH_REDIRECT,
redditConfig::$CLIENT_ID);
redditConfig::$ENDPOINT_OAUTH_REDIRECT);

//get JSON access token object (with refresh_token parameter)
$token = self::runCurl(redditConfig::$ENDPOINT_OAUTH_TOKEN, $postvals, null, true);
Expand All @@ -70,7 +69,7 @@ public function init_oauth(){
redditConfig::$SCOPES,
$state);

//forward user to Reddit auth page
//forward user to PayPal auth page
header("Location: $urlAuth");
}
}
Expand Down Expand Up @@ -369,69 +368,6 @@ public function getListing($sr, $limit = 5){
}
return self::runCurl($urlListing);
}

/**
* Get a wiki page
*
* Gets a specific wiki page from a subreddit
* @link http://www.reddit.com/dev/api#GET_wiki_{page}
* @param string $sr The subreddit name
* @param string $page The name of the wiki page
*/
public function getWikiPage($sr, $page) {
$urlWikiPage = "http://reddit.com/r/{$sr}/wiki/{$page}.json";
return self::runCurl($urlWikiPage);
}

/**
* Get a listing of wiki pages
*
* Gets a listing of wiki pages for a subreddit
* @link http://www.reddit.com/dev/api#GET_wiki_pages
* @param string $sr The subreddit name
*/
public function getWikiPages($sr) {
$urlWikiPages = "http://reddit.com/r/{$sr}/wiki/pages.json";
return self::runCurl($urlWikiPages);
}

/**
* Get a listing of Wiki page discussions
*
* Gets the listing of subreddits wiki page discussions
* @link http://www.reddit.com/dev/api#GET_wiki_discussions_{page}
* @param string $sr The subreddit name
* @param string $page The name of the wiki page
*/
public function getWikiPageDiscussion($sr, $page) {
$urlWikiPageDiscussions = "http://reddit.com/r/{$sr}/wiki/discussions/{$page}.json";
return self::runCurl($urlWikiPageDiscussions);
}

/**
* Get a listing of wiki revisions
*
* Gets a listing of a subreddit's wiki pages revisions
* @link http://www.reddit.com/dev/api#GET_wiki_revisions
* @param string $sr The subreddit name
*/
public function getWikiRevisions($sr) {
$urlWikiRevisions = "http://reddit.com/r/{$sr}/wiki/revisions.json";
return self::runCurl($urlWikiRevisions);
}

/**
* Get a listing of wiki page revisions
*
* Gets a listing of a specific wiki page's revisions
* @link http://www.reddit.com/dev/api#GET_wiki_revisions_{page}
* @param string $sr The subreddit name
* @param string $page The name of the wiki page
*/
public function getWikiPageRevisions($sr, $page) {
$urlWikiPageRevisions = "http://reddit.com/r/{$sr}/wiki/revisions/{$page}.json";
return self::runCurl($urlWikiPageRevisions);
}

/**
* Search all subreddits
Expand Down

0 comments on commit cf62ce1

Please sign in to comment.