Skip to content

Instantly share code, notes, and snippets.

@chaegumi
Created October 18, 2016 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chaegumi/c35897e9c7e53b408b44be6e43889c83 to your computer and use it in GitHub Desktop.
Save chaegumi/c35897e9c7e53b408b44be6e43889c83 to your computer and use it in GitHub Desktop.
<?php
set_time_limit(0);
// Set a valid header so browsers pick it up correctly.
header('Content-type: text/html; charset=utf-8');
// Emulate the header BigPipe sends so we can test through Varnish.
header('Surrogate-Control: BigPipe/1.0');
// Explicitly disable caching so Varnish and other upstreams won't cache.
header("Cache-Control: no-cache, must-revalidate");
// Setting this header instructs Nginx to disable fastcgi_buffering and disable
// gzip for this request.
header('X-Accel-Buffering: no');
if (ob_get_level() == 0) ob_start();
ob_implicit_flush(true);
ob_end_flush();
$file_content = file_get_contents(dirname(__FILE__) . '/emoticons.json');
$objs = json_decode($file_content);
echo "Start down<br />\n";
foreach($objs as $k=>$obj){
$file_content1 = file_get_contents($obj->url);
file_put_contents($obj->md5 . '.gif', $file_content1);
echo "Downloading " . $k . "<br />\n";
sleep(1);
}
echo "Download Complete<br />\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment