Created
July 8, 2021 19:57
-
-
Save someguy9/a480520597b71fe26645a0536c273ba5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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