-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapi.php
More file actions
45 lines (37 loc) · 1.09 KB
/
Copy pathapi.php
File metadata and controls
45 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
// Step tree: Call the API
include_once "../../../autoload.php";
// very small boot file. Starts session. Defines constants.
include_once "boot.php";
// Use the githubapi
use diversen\githubapi;
// We have a access token and we can now call the api:
$api = new githubapi();
// Simple call - get current users credentials
// This can also be done without scope
$command = "/user";
$res = $api->apiCall($command, 'GET', null);
if (!$res) {
print_r($api->errors); die;
}
print_r($res);
// Or: more complex: first param is the command
// The next is the REQUEST Method
// 3. is an array with $post if we .eg. PATCH, or POST
// $res = $api->apiCall('/gists/4381068', 'PATCH', $content);
/*
* $content = array (
'description' => 'mmmmmmmm....',
'public' => 'true',
'files' => array (
'file7.txt' => array (
'content' => 'New content from api'
),
),
);
*/
// PATCH a gist - you will need to set the correct scope, e.g. 'user,gist'
// $res = $api->apiCall('/gists/4381068', 'PATCH', $content);
// $http_ret_code
// return code
//echo $api->returnCode;