-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56cc727
commit c4c4018
Showing
3 changed files
with
66 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$username = 'Put your github username here'; | ||
$password = 'Put your github password here'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
class Github { | ||
public $repo; | ||
|
||
private $username; | ||
private $password; | ||
|
||
public function __construct($username, $password) { | ||
$this->username = $username; | ||
$this->password = $password; | ||
} | ||
|
||
public function post($url, $json, $patch = false) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password"); | ||
curl_setopt($ch, CURLOPT_URL, "https://api.github.com$url"); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
curl_setopt($ch, CURLOPT_HEADER, false); | ||
curl_setopt($ch, CURLOPT_POST, true); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | ||
if ($patch) { | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); | ||
} | ||
$ret = curl_exec($ch); | ||
if(!$ret) { | ||
trigger_error(curl_error($ch)); | ||
} | ||
curl_close($ch); | ||
return $ret; | ||
} | ||
|
||
public function add_milestone($data) { | ||
return json_decode(github_post("/repos/$this->repo/milestones", | ||
json_encode($data)), true); | ||
} | ||
|
||
public function add_issue($data) { | ||
return json_decode(github_post("/repos/$this->repo/issues", | ||
json_encode($data)), true); | ||
} | ||
|
||
public function add_comment($issue, $body) { | ||
return json_decode(github_post("/repos/$this->repo/issues/$issue/comments", | ||
json_encode(array('body' => $body))), true); | ||
} | ||
|
||
public function update_issue($issue, $data) { | ||
return json_decode(github_post("/repos/$this->repo/issues/$issue", | ||
json_encode($data), true), true); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters