Last active
June 15, 2017 04:39
-
-
Save scrummitch/647e090b95ac3fa5250244ba301d41a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function page($page = 1) { | |
$request = (new \GuzzleHttp\Client()) | |
->get('https://api.github.com/repos/user/repo/pulls', [ | |
'auth' => ['username', 'password'], | |
'headers' => [ | |
'User-Agent' => 'CSV export', | |
'Accept' => 'application/vnd.github.v3+json', | |
], | |
'query' => [ | |
'since' => '2016-06-01T00:00:00Z', | |
'state' => 'all', | |
'per_page' => 100, | |
'page' => $page | |
], | |
]); | |
return json_decode($request->getBody()->getContents()); | |
} | |
Route::get('csv', function() { | |
$pages = 2; | |
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 = page($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
Typo: filename=github-isuses.csv