Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created February 10, 2013 13:04
Show Gist options
  • Select an option

  • Save Darkflib/4749530 to your computer and use it in GitHub Desktop.

Select an option

Save Darkflib/4749530 to your computer and use it in GitHub Desktop.
fontsquirrel grabber, using their open api. Please don't abuse their great service.
<?php
$data=file_get_contents('http://www.fontsquirrel.com/api/fontlist/all');
$json=json_decode($data,true);
function grabfont($fontname) {
$url='http://www.fontsquirrel.com/fontfacekit/'.$fontname;
$fp=fopen('fonts/'.$fontname.'.zip','w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
//print_r($json);
foreach($json as $font) {
echo $font['foundry_name']."\n";
grabfont($font['foundry_urlname']);
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment