get() public method

See also: createRequest()
See also: request()
public get ( $urlPath, array $parameters = [], array $headers = [] ) : Milo\Github\Http\Response
$parameters array
$headers array
return Milo\Github\Http\Response
Example #1
0
 public function __construct(Github\OAuth\Login $login, Github\Api $api, Nette\Http\Session $session)
 {
     $session = $session->getSection('milo.github.nette-extension.user');
     if ($login->hasToken()) {
         $token = $login->getToken();
         $hash = sha1($token->getValue());
         if ($session->hash !== $hash) {
             $info = $this->defaults;
             $user = $api->decode($api->get('/user'));
             $info['id'] = $user->id;
             $info['login'] = $user->login;
             $info['name'] = $user->name;
             $info['avatarUrl'] = $user->avatar_url;
             if ($token->hasScope('user:email')) {
                 $emails = $api->decode($api->get('/user/emails'));
                 foreach ($emails as $email) {
                     $info['email'] = $email->email;
                     if ($email->primary) {
                         break;
                     }
                 }
             }
             $session->info = $info;
             $session->hash = $hash;
         }
         $this->isLoggedIn = TRUE;
     } else {
         $session->remove();
         $session->info = $this->defaults;
     }
     $this->info = $session->info;
 }
 public function init()
 {
     parent::init();
     $api = new GitHubApi();
     //$token = new MyToken('833e3c356b24acecf75b52aa815ab48c82ad21ef');
     //$api->setToken($token);
     //$api->getToken();
     // project's info http://developer.github.com/v3/repos/#get
     $this->response_proj = $api->get('/repos/:owner/:repo', ['owner' => $this->owner, 'repo' => $this->repo]);
     $this->response_proj = (array) $api->decode($this->response_proj);
     // contributor's info http://developer.github.com/v3/repos/#list-contributors
     $this->response_contributor = $api->get('/repos/:owner/:repo/contributors', ['owner' => $this->owner, 'repo' => $this->repo]);
     $this->response_contributor = (array) $api->decode($this->response_contributor);
 }
 public function init()
 {
     parent::init();
     // search projects http://developer.github.com/v3/search/#search-repositories
     $api = new GitHubApi();
     $this->search = $api->get('/search/repositories?q=' . str_replace(' ', '+', $this->search), []);
     $this->search = (array) $api->decode($this->search);
     $this->search = $this->search['items'];
 }
Example #4
0
 public function __construct($id, $url)
 {
     $this->content = apcu_fetch('cachecontrol_' . $id);
     if (!$this->content || isset($_GET['nocache'])) {
         $api = new Github\Api();
         $response = $api->get($url);
         $this->content = $api->decode($response);
         apcu_store('cachecontrol_' . $id, $this->content, 300);
     }
 }
 public function init()
 {
     parent::init();
     $api = new GitHubApi();
     //$token = new MyToken('833e3c356b24acecf75b52aa815ab48c82ad21ef');
     //$api->setToken($token);
     //$api->getToken();
     // contributors' info http://developer.github.com/v3/users/#get-a-single-user
     $this->user = $api->get('/users/:username', ['username' => $this->user]);
     $this->user = (array) $api->decode($this->user);
     // define contributors' status
     $this->status = GithubUsers::find()->where(['id_user' => $this->user['id']])->one();
     $this->status = $this->status['status_user'];
 }
Example #6
0
 } catch (Exception $e) {
     //echo $e->getMessage();
 }
 try {
     $api = new Github\Api();
     $token = new Github\OAuth\Token("{{site.github_key}}");
     $api->setToken($token);
     foreach ($api->paginator('/repos/amplab/tachyon/contributors') as $response) {
         array_push($contributors, $api->decode($response));
     }
     foreach ($contributors as $contributorPage) {
         foreach ($contributorPage as $contributor) {
             array_push($contributorsMin, array('login' => $contributor->login, 'avatar_url' => $contributor->avatar_url, 'contributions' => $contributor->contributions));
         }
     }
     $response = $api->get('/repos/amplab/tachyon');
     $repoInfo = $api->decode($response);
     $stars = $repoInfo->stargazers_count;
     $commits = 0;
     foreach ($contributorsMin as $contributor) {
         $commits += $contributor['contributions'];
     }
     array_push($stats, array('stars' => $stars, 'commits' => $commits, 'contributors' => count($contributorsMin)));
     $response = $api->get('/repos/amplab/tachyon/releases');
     $releases = $api->decode($response);
     foreach ($releases as $release) {
         if (strtotime($release->created_at) > microtime(true) - $pastNewsLimit) {
             array_push($news, array("title" => "[RELEASE] " . $release->name, "date" => 1000 * strtotime($release->created_at), "link" => $release->html_url, "type" => "github"));
         }
     }
 } catch (Exception $e) {