-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamples.php
More file actions
59 lines (46 loc) · 1.51 KB
/
Copy pathsamples.php
File metadata and controls
59 lines (46 loc) · 1.51 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
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
include('ghclient.php');
// defined in defines.inc
global $APIURL;
global $APIKEY;
function showRateLimitInfo($ghc)
{
echo "Rate limit: {$ghc->getRateLimit()}\n";
echo "Rate limit remaining: {$ghc->getRateLimitRemaining()}\n";
echo "Rate limit resets at: {$ghc->getRateLimitResetTime()}\n";
}
$client = new ghclient($APIKEY, null);
$client->setDebug(true);
// show who I am and my details
$url = $APIURL . '/user';
$user_data = $client->request($url);
if (empty($user_data))
{
echo "Error getting user data; can't proceed further!\n";
exit(1);
}
echo json_encode($user_data, JSON_PRETTY_PRINT) . "\n";
showRateLimitInfo($client);
// show one repo
/*
$url = $user_data['repos_url'];
//$client->setPageSize(1);
//$client->setPage();
$repos = $client->request($url);
echo json_encode($repos, JSON_PRETTY_PRINT) . "\n";
showRateLimitInfo($client);
*/
// create a new file
/*
$url = $APIURL . '/repos/mromaine/github-api-play/contents/testfile.txt';
$content = base64_encode('Nothing to see here; move along.');
$data = array('message' => 'scripted file creation test', 'committer' => array('name' => 'matt romaine', 'email' => 'mromaine@gmail.com'), 'content' => $content);
$retval = $client->request($url, 'PUT', $data, 201);
echo json_encode($retval, JSON_PRETTY_PRINT) . "\n";
showRateLimitInfo($client);
*/
// show events for this repository
$url = $APIURL . '/repos/mromaine/github-api-play/events';
$retval = $client->request($url);
echo json_encode($retval, JSON_PRETTY_PRINT) . "\n";
showRateLimitInfo($client);