Skip to content

Instantly share code, notes, and snippets.

@Cyclonecode
Created May 17, 2023 10:33
Show Gist options
  • Select an option

  • Save Cyclonecode/df2555edc2f5e1be7ebe9507991495f7 to your computer and use it in GitHub Desktop.

Select an option

Save Cyclonecode/df2555edc2f5e1be7ebe9507991495f7 to your computer and use it in GitHub Desktop.
# get repository content
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/$this->username/$this->repository/contents/README.md");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/vnd.github+json',
'X-Github-Api-Version: 2022-11-28',
'Authorization: Bearer ' . $this->token,
]);
curl_setopt($ch, CURLOPT_USERAGENT, 'my-user-agent');
$response = curl_exec($ch);
$response = \json_decode($response);
$readmeContent = base64_decode($response->content);
# get tags
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/$this->username/$this->repository/tags");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/vnd.github+json',
'X-Github-Api-Version: 2022-11-28',
'Authorization: Bearer ' . $this->token,
]);
curl_setopt($ch, CURLOPT_USERAGENT, 'my-user-agent');
$response = curl_exec($ch);
$response = \json_decode($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment