Skip to content

Instantly share code, notes, and snippets.

@someguy9
Created July 8, 2021 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someguy9/a480520597b71fe26645a0536c273ba5 to your computer and use it in GitHub Desktop.
Save someguy9/a480520597b71fe26645a0536c273ba5 to your computer and use it in GitHub Desktop.
//URLBOX
function urlbox_url_generate($url, $options){
$options['url'] = $url;
$options['url'] = preg_replace("(^https?://)", "", $options['url'] );
$format = isset($options['format']) ? $options['format'] : 'png';
unset($options['format']);
$_parts = [];
foreach ($options as $key => $values) {
$values = is_array($values) ? $values : [$values];
foreach ($values as $value) {
if(!empty($value)){
$encodedValue = sanitizeValue($value);
$_parts[] = "$key=$encodedValue";
}
}
}
$query_string = implode("&", $_parts);
$TOKEN = hash_hmac("sha1", $query_string, 'YOUR API SECRET');
return "https://api.urlbox.io/v1/YOUR-API-KEY/$TOKEN/$format?$query_string";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment