Skip to content

Instantly share code, notes, and snippets.

@Ranthrall
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save Ranthrall/c8efb08a0629e8bb4895 to your computer and use it in GitHub Desktop.

Select an option

Save Ranthrall/c8efb08a0629e8bb4895 to your computer and use it in GitHub Desktop.
PHP to retrieve emoji from Github API
<?php
function url_get_contents ($url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT,'curl/7.43.0');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
};
$json = url_get_contents('https://api.github.com/emojis');
$emojis = json_decode($json);
foreach ($emojis as $name => $img) {
echo ":$name: --&gt; <img src='$img'><br />";
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment