Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 7 additions & 25 deletions githubapi_class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class GitHubAPI {
$this->curl->setHeader('Content-Type', 'application/json');
$this->curl->setUserAgent('Backdrop CMS GitHub API module');
$this->curl->setHeader('Accept', '*/*');
$this->curl->setHeader('Authorization', 'token ' . $this->getToken());
}

/**
Expand Down Expand Up @@ -380,10 +381,6 @@ class GitHubAPI {
public function getRequest($command, $params = array(), $headers = array()) {
$this->prepareCommand($command, $params);

if ($this->getToken()) {
$params['access_token'] = $this->getToken();
}

// Add default 1000 per page.
$params['per_page'] = $this->per_page;

Expand All @@ -408,7 +405,7 @@ class GitHubAPI {
*
* @access protected
* @param $command
* String value. GitHub API url with tokens like :owner, :repo and ect.
* String value. GitHub API url with tokens like :owner, :repo and etc.
* @param $params array
* Values for request and tokens for request url. LIke :owner, :repo, :id and etc.
* @return stdClass|FALSE
Expand All @@ -419,13 +416,8 @@ class GitHubAPI {
//$params['committer'] = $this->getCommittrer();
$this->prepareCommand($command, $params);

$query = '';
if ($this->getToken()) {
$query = '?access_token=' . $this->getToken();
}

$this->reInitCurl();
$this->curl->put(GITHUB_API_URI . '/' . $command . $query, $params);
$this->curl->put(GITHUB_API_URI . '/' . $command, $params);
$response = $this->getResponse();
return $response;
}
Expand All @@ -444,12 +436,8 @@ class GitHubAPI {
public function postRequest($command, $params = array()) {

$this->prepareCommand($command, $params);
$query = '';
if ($this->getToken()) {
$query = '?access_token=' . $this->getToken();
}
$this->reInitCurl();
$this->curl->post(GITHUB_API_URI . '/' . $command . $query, $params);
$this->curl->post(GITHUB_API_URI . '/' . $command, $params);
$response = $this->getResponse();
return $response;
}
Expand All @@ -466,17 +454,11 @@ class GitHubAPI {
* FALSE if request failed. Object if success.
*/
public function deleteRequest($command, $params = array()) {

$this->prepareCommand($command, $params);

$query = '';
if ($this->getToken()) {
$query = '?access_token=' . $this->getToken();
}

$this->reInitCurl();
$this->curl->delete(GITHUB_API_URI . '/' . $command . $query, $params);
$this->curl->delete(GITHUB_API_URI . '/' . $command, $params);
$response = $this->getResponse();

return $response;
}

Expand All @@ -486,7 +468,7 @@ class GitHubAPI {
*
* @access private
* @param $command
* String value. GitHub API url with tokens like :owner, :repo and ect.
* String value. GitHub API url with tokens like :owner, :repo and etc.
* @param $params array
* Values for request and tokens for request url. LIke :owner, :repo, :id and etc.
*/
Expand Down