add reopen example
This commit is contained in:
22
Gitea.php
22
Gitea.php
@@ -1,26 +1,32 @@
|
||||
<?php
|
||||
class Gitea{
|
||||
|
||||
|
||||
public function __construct($url,$user,$pass){
|
||||
$this->url=$url;
|
||||
$this->user=$user;
|
||||
$this->pass=$pass;
|
||||
}
|
||||
|
||||
public function getIssues($user,$repo){
|
||||
public function forIssues($user,$repo,$callback,$args){
|
||||
$page=1;
|
||||
while(1){
|
||||
$issues=$this->request("repos/$user/$repo/issues?page=$page");
|
||||
$issues=$this->request("repos/$user/$repo/issues?page=$page&".http_build_query($args));
|
||||
if(!$issues) break;
|
||||
foreach($issues as $issue){
|
||||
echo $issue->number."\n";
|
||||
call_user_func($callback,$issue);
|
||||
}
|
||||
$page++;
|
||||
}
|
||||
}
|
||||
|
||||
public function request($url, $postFields = null){
|
||||
$url=$this->url.$url;
|
||||
public function editIssue($issue,$args){
|
||||
$this->request($issue->url,$args,true);
|
||||
}
|
||||
|
||||
public function request($url, $postFields = null, $patch=false){
|
||||
if(substr($url,0,4)!='http'){
|
||||
$url=$this->url.$url;
|
||||
}
|
||||
echo ">> $url\n";
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Bot');
|
||||
@@ -30,6 +36,10 @@ class Gitea{
|
||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
if($patch){
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
||||
}
|
||||
|
||||
if (!is_null($postFields)) {
|
||||
$postFields = json_encode($postFields);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
|
Reference in New Issue
Block a user