From cf62ce168e969bf739891fdb4f88f988538df632 Mon Sep 17 00:00:00 2001 From: jcleblanc Date: Thu, 5 Nov 2015 21:19:57 -0500 Subject: [PATCH] adjusted auth URLs, incremented SSL version (remove 403 errors), and modified auth req object --- config.php | 6 ++--- reddit.php | 70 +++--------------------------------------------------- 2 files changed, 6 insertions(+), 70 deletions(-) diff --git a/config.php b/config.php index ae1f26e..20108aa 100644 --- a/config.php +++ b/config.php @@ -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 diff --git a/reddit.php b/reddit.php index 6b80be4..efac676 100644 --- a/reddit.php +++ b/reddit.php @@ -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); @@ -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"); } } @@ -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