index.php 894 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * TODO:
  4. *
  5. * Rewrite this. Shouldnt be a test file, like its now.
  6. *
  7. * */
  8. define('BASE_PATH', realpath(dirname(__FILE__)));
  9. define('API_URL', 'https://git.giaever.org/api/v1');
  10. define('API_TOKEN', '');
  11. function my_autoloader($class)
  12. {
  13. $file = str_replace("\\", DIRECTORY_SEPARATOR, strtolower($class)) . ".php";
  14. echo $class . ' -> ' . $file . "\n";
  15. require_once BASE_PATH . DIRECTORY_SEPARATOR . $file;
  16. }
  17. spl_autoload_register('my_autoloader');
  18. try {
  19. $client = new \Client\GogsAPI(API_URL, API_TOKEN);
  20. $me = $client->user()->load();
  21. $you = $client->user("INF3910-3-CSS-IoT")->load();
  22. $mine = $me->get("/repos")->load();
  23. //$yours = $you->get("/repos")->load();
  24. //$me->get("/tokens")->load();
  25. } catch (\Lib\NotAuthorizedException $e) {
  26. die($e->getMessage());
  27. } catch (\Lib\HTTPUnexpectedResponse $e) {
  28. die($e->getMessage());
  29. }
  30. ?>