Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
moved dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
khicks committed Nov 5, 2015
1 parent ea57569 commit 1408f1f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,3 +1,3 @@
.idea/
phapper/config.php
config.php
run.php
File renamed without changes.
21 changes: 21 additions & 0 deletions docs/gettingstarted.rst
@@ -0,0 +1,21 @@
Getting Started
===============

To start using Phapper, download the `Phapper files from GitHub <https://github.com/rotorcowboy/Phapper>`_. You can either download the ZIP file and extract it yourself or do a git clone:

.. code-block::
$ git clone git@github.com:rotorcowboy/Phapper.git
Once you've obtained the files, enter the ``Phapper/`` directory and move or copy ``config.sample.php`` to ``config.php`` and fill in the missing values for username, password, etc.

Then, you can start creating your script. Create a new file in the ``Phapper`` directory (or elsewhere) and insert this code to initialize Phapper:

.. code-block:: php
<?php
require_once("src/phapper.php");
$r = new \Phapper\Phapper();
Congratulations! You're ready to start using Phapper!
File renamed without changes.
6 changes: 4 additions & 2 deletions phapper/inc/oauth2.php → src/inc/oauth2.php
Expand Up @@ -14,13 +14,15 @@ class OAuth2 {
private $app_id;
private $app_secret;
private $user_agent;
private $endpoint;

public function __construct($username, $password, $app_id, $app_secret, $user_agent) {
public function __construct($username, $password, $app_id, $app_secret, $user_agent, $endpoint) {
$this->username = $username;
$this->password = $password;
$this->app_id = $app_id;
$this->app_secret = $app_secret;
$this->user_agent = $user_agent;
$this->endpoint = $endpoint;

$this->requestAccessToken();
}
Expand All @@ -37,7 +39,7 @@ public function getAccessToken() {
}

private function requestAccessToken() {
$url = "https://www.reddit.com/api/v1/access_token";
$url = "{$this->endpoint}/api/v1/access_token";
$params = array(
'grant_type' => 'password',
'username' => $this->username,
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions phapper/phapper.php → src/phapper.php
Expand Up @@ -2,10 +2,10 @@

namespace Phapper;

require_once('config.php');
require_once('inc/oauth2.php');
require_once('inc/ratelimiter.php');
require_once('inc/live.php');
require_once(__DIR__.'/../config.php');
require_once(__DIR__.'/inc/oauth2.php');
require_once(__DIR__.'/inc/ratelimiter.php');
require_once(__DIR__.'/inc/live.php');


class Phapper {
Expand All @@ -31,7 +31,7 @@ public function __construct($username = null, $password = null, $app_id = null,
$reddit_basic_endpoint = (is_null($basic_endpoint)) ? PhapperConfig::$basic_endpoint : $basic_endpoint;
$reddit_oauth_endpoint = (is_null($oauth_endpoint)) ? PhapperConfig::$oauth_endpoint : $oauth_endpoint;

$this->oauth2 = new OAuth2($reddit_username, $reddit_password, $reddit_app_id, $reddit_app_secret, $phapper_user_agent);
$this->oauth2 = new OAuth2($reddit_username, $reddit_password, $reddit_app_id, $reddit_app_secret, $phapper_user_agent, $reddit_basic_endpoint);
$this->ratelimiter = new RateLimiter(true, 1);
$this->user_agent = $phapper_user_agent;
$this->basic_endpoint = $reddit_basic_endpoint;
Expand Down

0 comments on commit 1408f1f

Please sign in to comment.