123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- require "./src/gpac.php";
- use Gogs\Lib\Curl\Exception as ApiException;
- define('API_URL', 'https://git.giaever.org/api/v1');
- define("API_TOKEN", 'e14b9eff0749b6f0c4cadf4bb72b83d44578ae');
- try {
- $client = new Gogs\API\Client(API_URL, API_TOKEN);
- $me = $client->user()->load();
- $user_search = $client->users()->search(array(
- "name" => "tester2"
- ));
- if ($user_search->len() > 0)
- echo " * Found user(s) " . var_export($user_search, true);
- else
- echo " * User 'tester2' not found";
- try {
- echo " * Creating new repo under autorized user: " . $me->username;
-
- $repo = $me->repos()->create(
- "gogs-php-api-client-test",
- "Repository created from test file.",
- false,
- true,
- "Vim",
- "MIT License"
-
- );
-
- echo "New repo '" . $repo->full_name . "' created!\n";
- } catch(ApiException\HTTPUnexpectedResponse $e) {
-
- $repo = $me->repo("gogs-php-api-client-test");
-
- $repo->delete();
- echo "Repo '" . $repo->full_name . "' deleted\n";
- }
-
- foreach($me->organizations()->load()->all() as $org)
- var_dump("ORG", $org->username);
- echo sprintf(
- "org->username: %s\norg->org_username: %s\norg->user_username: %s\n",
- $org->username, $org->org_username, $org->user_username
- );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- } catch (ApiException\NotAuthorizedException $e) {
- die("NOT AUTH: " . $e->getMessage());
- } catch (ApiException\HTTPUnexpectedResponse $e) {
- die($e);
- } catch (Exception $e) {
- die($e);
- }
- ?>
|