wechat-emoticon
wechat-emoticon copied to clipboard
php版本下载
<?php
define("CURRENT_PATH", dirname(__FILE__));
$jsonUrl = "https://raw.githubusercontent.com/spacelan/wechat-emoticon/master/emoticons.json";
$dirName = 'images';
if (!is_dir(CURRENT_PATH . '/' . $dirName)) {
if (mkdir(CURRENT_PATH . '/' . $dirName) == true) {
echo $dirName . ' create success!' . PHP_EOL;
} else {
echo $dirName . ' create failed!' . PHP_EOL;
die;
}
}
$urlList = json_decode(file_get_contents($jsonUrl), true);
if (!is_array($urlList)) {
echo 'json file fetch failed!' . PHP_EOL;
die;
}
foreach($urlList as $key=>$url) {
$filename = CURRENT_PATH . '/' . $dirName . '/image_' . $key . '.gif';
echo 'Info :' . $filename . ' downloading' . PHP_EOL;
$fp = fopen($filename, 'w');
if ($fp === false) {
echo 'Notice: ' . $filename . ' Open failed!' . PHP_EOL;
continue;
}
$ret = fwrite($fp, file_get_contents(($url['url'])));
if ($ret === false) {
echo 'Notice: ' . $filename . ' Write failed!' . PHP_EOL;
}
fclose($fp);
}