Skip to content

Instantly share code, notes, and snippets.

@urlbox
Last active December 13, 2015 20:08
Show Gist options
  • Save urlbox/4967567 to your computer and use it in GitHub Desktop.
Save urlbox/4967567 to your computer and use it in GitHub Desktop.
PHP Urlbox Snippet
<?php
function urlbox($url, $args)
{
$URLBOX_APIKEY = "xxx-xxx";
$URLBOX_SECRET = "xxx-xxx";
$options['url'] = urlencode($url);
$options += $args;
foreach ($options as $key => $value) {
$_parts[] = "$key=$value";
}
$query_string = implode("&", $_parts);
$TOKEN = hash_hmac("sha1", $query_string, $URLBOX_SECRET);
return "https://api.urlbox.io/v1/$URLBOX_APIKEY/$TOKEN/png?$query_string";
}
$options['width'] = "1024";
$options['height'] = "768";
$options['full_page'] = 'true';
$options['force'] = 'true';
$apicallUrl = urlbox("google.com", $options);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment