-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
30 lines (21 loc) · 775 Bytes
/
index.php
File metadata and controls
30 lines (21 loc) · 775 Bytes
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
<?php
require_once 'vendor/autoload.php';
header('Access-Control-Allow-Origin: *');
\Slim\Slim::registerAutoloader();
// Create an instance of Slim
$app = new \Slim\Slim();
$app->get('/api/:name', function ($name) {
$name = str_replace(array(" ", "+"),"/", $name);
$client = new Github\Client();
$method = Github\Client::AUTH_URL_CLIENT_ID;
$filename = "config/githubApp.txt";
$lines = file($filename, FILE_IGNORE_NEW_LINES);
$usernameOrToken = $lines[1];
$password = $lines[3];
$client->authenticate($usernameOrToken, $password, $method);
$contributors = $client->getHttpClient()->get($name);
header('Content-Type', 'application/json');
echo json_encode($contributors->getContent());
});
// Run Slim app
$app->run();