diff --git a/Gitea.php b/Gitea.php index 9f6361c..7007bc0 100644 --- a/Gitea.php +++ b/Gitea.php @@ -7,10 +7,14 @@ class Gitea{ $this->pass=$pass; } - public function forIssues($user,$repo,$callback,$args){ + public function forIssues($user,$repo,$callback,$args=null){ $page=1; while(1){ - $issues=$this->request("repos/$user/$repo/issues?page=$page&".http_build_query($args)); + $url="repos/$user/$repo/issues?page=$page"; + if($args){ + $url.='&'.http_build_query($args); + } + $issues=$this->request($url); if(!$issues) break; foreach($issues as $issue){ call_user_func($callback,$issue); @@ -20,16 +24,16 @@ class Gitea{ } public function editIssue($issue,$args){ - $this->request($issue->url,$args,true); + return $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"; + echo ">> $url ".json_encode($postFields).' '.json_encode($patch)." <<\n"; $ch = curl_init(); - curl_setopt($ch, CURLOPT_USERAGENT, 'Bot'); + curl_setopt($ch, CURLOPT_USERAGENT, 'james/GiteaBot'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);