-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_github.php
62 lines (51 loc) · 1.09 KB
/
base_github.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
<?php
/**
*
* Base class for github
*
* Classname : base_github
* Filename : base_github.php
* Author : Vignesh
*
*/
if (!function_exists('curl_init')) {
throw new Exception('Github needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
throw new Exception('Github needs the JSON PHP extension.');
}
class base_github {
/*
* curls the given url
* */
protected function curl($url, $method, $postdata=NULL ){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($method == "POST" && $postdata!=NULL)
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$output = curl_exec($ch);
curl_close($ch);
if($output){
return $output;
} else {
return FALSE;
}
}
/*
* converts stdobject to array
* */
protected function objectToArray($data){
if (is_object($data)) {
$data = get_object_vars($data);
}
if (is_array($data)) {
return array_map(array($this, __FUNCTION__) , $data);
}
else {
return $data;
}
}
}
?>