123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /*
- * TODO:
- *
- * Rewrite this. Shouldnt be a test file, like its now.
- *
- * */
- 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);
- //$users = $client->users()->search(array("name" => "bje007"));
- $me = $client->user()->load();
-
- try {
- // Create new repo
- $repo = $me->repos()->new(
- /*name*/ "gogs-php-api-client-test",
- /*desc*/ "Repository created from test file.",
- /*private*/ false,
- /*auto init*/ true,
- /*git ignore*/ "Vim",
- /*license*/ "MIT License"
- /* default read me */
- );
- echo "New repo created!\n";
- } catch(\Lib\HTTPUnexpectedResponse $e) {
- // Repo exists, get it!
- $repo = $me->repo("gogs-php-api-client-test");
- // Delete it (it will now be created on reload!)
- $repo->delete();
- echo "Repo deleted\n";
- }
- } catch (\Lib\NotAuthorizedException $e) {
- die("NOT AUTH: " . $e->getMessage());
- } catch (\Lib\HTTPUnexpectedResponse $e) {
- die($e);
- }
- ?>
|