IDT v1 Export
The snippet can be accessed without any authentication.
Authored by
Erick Hitter
<?php
$api_key = '';
$api = 'https://idonethis.com/api/v0.0/dones/';
$page = 1;
$url = $api;
do {
echo "Doing page #{$page}:\n{$url}\n\n";
$curl = curl_init();
curl_setopt_array(
$curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_ENCODING => '',
CURLOPT_HTTPHEADER => array(
'Content-type:application/json',
'Authorization: Token ' . $api_key,
),
)
);
$_results = curl_exec( $curl );
if ( curl_error( $curl ) ) {
echo "Something failed requesting `{$url}`.\n\n";
exit;
}
$results = json_decode( $_results );
curl_close( $curl );
$url = $results->next;
file_put_contents( 'idt_export_page_' . str_pad( $page, 3, 0, STR_PAD_LEFT ) . '.json', $_results );
++$page;
$sleep = rand( 1, 3 );
echo "Sleeping for {$sleep} seconds...\n\n\n";
sleep( $sleep );
} while ( null != $url );
Please register or sign in to comment