Tyler Perkins
bd966f576b
All checks were successful
continuous-integration/drone/push Build is passing
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
class Gitea {
|
|
private $giteaToken;
|
|
|
|
public function __construct(String $token) {
|
|
$this->giteaToken = $token;
|
|
}
|
|
|
|
public function getResumeReleases() : String {
|
|
$curl = curl_init();
|
|
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/repos/tyler/Resume/releases?per_page=1&access_token=" . $this->giteaToken);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$result = curl_exec($curl);
|
|
if(!$result){
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
die();
|
|
}
|
|
|
|
curl_close($curl);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
public function getRecentProjects() : array {
|
|
$curl = curl_init();
|
|
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/user/repos?page=1&limit=100&access_token=" . $this->giteaToken);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$result = curl_exec($curl);
|
|
if(!$result){
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
die();
|
|
}
|
|
|
|
curl_close($curl);
|
|
//now we need to parse out the results into a nice array containing the
|
|
//most recent items
|
|
|
|
$parsed = json_decode($result, true);
|
|
|
|
$ret = array();
|
|
|
|
foreach($parsed as $item){
|
|
array_push($ret, $item);
|
|
}
|
|
|
|
usort($ret, "datecmp");
|
|
return $ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function datecmp($lhs, $rhs) {
|
|
return $lhs["updated_at"] < $rhs["updated_at"];
|
|
}
|
|
?>
|