You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library now does all the json encoding and decoding for you.
There is a new $token_file argument when you initiate the class. This
will be used as the full path to the file where the github oauth token
will be stored for future use.
Fixed the post_request method so that it now properly encodes and
passes the data through.
Copy file name to clipboardExpand all lines: README.md
+24-11
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,31 @@
1
1
# GitHubOAuth PHP Library
2
-
2
+
3
+
3
4
This library provides a very simple PHP interface to the GitHub oAuth API v3. Just a few lines of code and you are ready to go!
4
5
5
6
You need to [register the application](https://github.com/account/applications/new) that you intend to use this library with GitHub. The OAuth keys provided will only work for the one domain that registered. Therefore, if you have multiple domains, you that you would like to run this library on, you will be required to register each domain and obtain a unique set of OAuth keys for each domain.
6
7
7
8
I ultimately developed this library becuase I wanted to give access to my github issues of my private repositories to my customers. This way my customers can see what bugs exist and see what I am working on. Take a look at my [Known Issues & Requests](http://joeworkman.net/rapidweaver/issues) page on my website that displays all issues for on of my private repos. you can even drill down into each individual issue and see all of its comments. While all of this is read-only, you could easily add modification and creation abilities using this library. Pretty cool huh!?!
8
-
9
-
## Requirements
9
+
10
+
11
+
12
+
## Requirements
13
+
14
+
10
15
* PHP5.1+
11
16
* cURL Extension
12
17
13
-
## Usage
18
+
## Usage
19
+
20
+
14
21
First you need to load the class…
15
22
16
23
require_once('github_oauth.php');
17
24
18
-
Now we need to create our OAuth object. You will need to make sure that you obtain your OAuth Client ID and Secret key by [registering your app](https://github.com/account/applications/new) with the GitHub. You will also need to specify the scope of the access you are requesting. For more info on scope options, check out the [GitHub OAuth Docs](http://developer.github.com/v3/oauth/).
25
+
Now we need to create our OAuth object. You will need to make sure that you obtain your OAuth Client ID and Secret key by [registering your app](https://github.com/account/applications/new) with the GitHub. You will also need to specify the scope of the access you are requesting. *$token_file* is an optional argument for defining a centralized location to store the oauth token for future use. For more info on scope options, check out the [GitHub OAuth Docs](http://developer.github.com/v3/oauth/).
26
+
19
27
20
-
$oauth = new GitHubOauth($scope, $client_key, $secret_key);
28
+
$oauth = new GitHubOauth($scope, $client_key, $secret_key, $token_file);
21
29
22
30
The next block of code is where all the magic happens. This code will load a local cached copy of your OAuth access\_token. If one is not found, it will redirect the user to GitHub for authorization. Once the user authorizes the access, you will be redirected back to the original page where the class will generate the access\_token based off the code supplied by GitHub.
23
31
@@ -30,14 +38,18 @@ The next block of code is where all the magic happens. This code will load a loc
30
38
31
39
Now we are all set! We are fully authenticated and can make all the API queries that we want! **Make sure that your requests do not start with a "/"**.
32
40
33
-
$issues = json_decode($oauth->request("issues"));
41
+
$issues = $oauth->request("issues");
42
+
43
+
44
+
45
+
46
+
## Functions
34
47
35
48
36
-
37
-
## Functions
38
49
This class has eight public functions for you to use:
39
50
40
-
51
+
52
+
41
53
`set_keys($client_id, $secret)` allows you to set the oauth keys outside of the object creation. Chances are that you won't have to use this method.
42
54
43
55
@@ -63,7 +75,8 @@ This class has eight public functions for you to use:
63
75
64
76
65
77
## Examples
66
-
78
+
79
+
67
80
The `index.php` file included in this repo can serve as a simple example on how to get going.
68
81
69
82
For a live example, take a look at my [Known Issues & Requests](http://joeworkman.net/rapidweaver/issues) page on my website that displays all issues for on of my private repos. you can even drill down into each individual issue and see all of its comments. While all of this is read-only, you could easily add modification and creation abilities using this library.
0 commit comments