Skip to content

Instantly share code, notes, and snippets.

@scrummitch
Last active August 29, 2015 14:26
Show Gist options
  • Save scrummitch/b69855721b36acb49dcc to your computer and use it in GitHub Desktop.
Save scrummitch/b69855721b36acb49dcc to your computer and use it in GitHub Desktop.
Export github issues in your repo to a csv. Using kohana request library
<?php
$pages = 1;
function req($page = 1)
{
$request = Request::factory('https://api.github.com/repos/ORGANISATION/REPOSITORY/issues')
->headers('Authorization', 'Basic '.base64_encode('USERNAME:PASSWORD'))
->headers('User-Agent', 'CSV export')
->query([
'since' => '2014-07-01T00:00:00Z',
'state' => 'all',
'per_page' => 100,
'page' => $page
])
->execute();
return json_decode($request->body());
}
function github()
{
$this->auto_render = false;
header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename=\"github-isuses.csv\"');
$fp = fopen('php://output', 'w');
fputcsv($fp, [
'ID',
'Title',
'Created Date',
'Updated Date',
'Closed Date',
'Merged Date'
]);
for ($i = 1; $i <= ($pages+1); $i++) {
$new = req($i);
foreach($new AS $item) {
fputcsv($fp, [
$item->number,
$item->title,
$item->created_at,
$item->updated_at,
$item->closed_at,
$item->merged_at,
]);
}
}
fclose($fp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment