123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- define('BASE_PATH', realpath(dirname(__FILE__)));
- define('API_URL', 'https://git.giaever.org/api/v1');
- define('API_TOKEN', '142efbfd6fbdf147f03d289f8b22a438eaa1b5d1');
- function my_autoloader($class) {
- $file = str_replace("\\", DIRECTORY_SEPARATOR, strtolower($class)) . ".php";
- echo $class . ' -> ' . $file . "\n";
- require_once BASE_PATH . DIRECTORY_SEPARATOR . $file;
- }
- spl_autoload_register('my_autoloader');
- try {
- $client = new \Client\GogsAPI(API_URL, API_TOKEN);
-
- $me = $client->user()->load();
-
- try {
-
- $repo = $me->repos()->new(
- "gogs-php-api-client-test",
- "Repository created from test file.",
- false,
- true,
- "Vim",
- "MIT License"
-
- );
- echo "New repo created!\n";
- } catch(\Lib\HTTPUnexpectedResponse $e) {
-
- $repo = $me->repo("gogs-php-api-client-test");
-
- $repo->delete();
- echo "Repo deleted\n";
- }
- } catch (\Lib\NotAuthorizedException $e) {
- die("NOT AUTH: " . $e->getMessage());
- } catch (\Lib\HTTPUnexpectedResponse $e) {
- die($e);
- }
- ?>
|