-
Notifications
You must be signed in to change notification settings - Fork 46
/
EGithub.php
63 lines (42 loc) · 1.01 KB
/
EGithub.php
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
59
60
61
62
63
<?php
class EGithub extends CComponent
{
public static $apiBaseUrl = 'https://api.github.com/';
public $username = '';
public $password = '';
private $authMode = 0;
/**
* @todo: implement
*/
public function authenticatePassword()
{
}
/**
* @todo: implement
*/
public function authenticateOAuth()
{
}
public static function getApiBaseUrl()
{
return (substr(static::$apiBaseUrl, -1, 1) == '/') ?
substr(static::$apiBaseUrl, 0, -1) :
static::$apiBaseUrl;
}
public static function githubRequest($url, $requestType, $data)
{
$url = static::getApiBaseUrl() . $url;
$c = curl_init();
// if ($this->authMode == 0) {
// //@todo: add auth params
// }
// @todo: implement POST/DELETE/... request types
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($c);
curl_close($c);
return array(200, json_decode($response));
}
}