tidy indenting
This commit is contained in:
parent
1ba0f72145
commit
a777a798a2
75
Gitea.php
75
Gitea.php
@ -7,44 +7,43 @@ class Gitea{
|
|||||||
$this->pass=$pass;
|
$this->pass=$pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIssues($user,$repo){
|
public function getIssues($user,$repo){
|
||||||
$page=1;
|
$page=1;
|
||||||
while(1){
|
while(1){
|
||||||
$issues=$this->request("repos/$user/$repo/issues?page=$page");
|
$issues=$this->request("repos/$user/$repo/issues?page=$page");
|
||||||
if(!$issues) break;
|
if(!$issues) break;
|
||||||
foreach($issues as $issue){
|
foreach($issues as $issue){
|
||||||
echo $issue->number."\n";
|
echo $issue->number."\n";
|
||||||
|
}
|
||||||
|
$page++;
|
||||||
}
|
}
|
||||||
$page++;
|
}
|
||||||
|
|
||||||
|
public function request($url, $postFields = null){
|
||||||
|
$url=$this->url.$url;
|
||||||
|
echo ">> $url\n";
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Bot');
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
|
||||||
|
if (!is_null($postFields)) {
|
||||||
|
$postFields = json_encode($postFields);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
||||||
|
'Content-Length: '.strlen($postFields), ]);
|
||||||
|
}
|
||||||
|
if($this->user) {
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->pass);
|
||||||
|
}
|
||||||
|
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return json_decode($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request($url, $postFields = null)
|
|
||||||
{
|
|
||||||
$url=$this->url.$url;
|
|
||||||
echo ">> $url\n";
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Bot');
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
|
|
||||||
if (!is_null($postFields)) {
|
|
||||||
$postFields = json_encode($postFields);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
|
||||||
'Content-Length: '.strlen($postFields), ]);
|
|
||||||
}
|
|
||||||
if($this->user) {
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
|
||||||
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->pass);
|
|
||||||
}
|
|
||||||
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$result = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
return json_decode($result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user