Skip to content

Instantly share code, notes, and snippets.

@gugu
Created November 15, 2016 21:26
Show Gist options
  • Save gugu/b2d9dd70e5b2f7df2343d5fc1be4718f to your computer and use it in GitHub Desktop.
Save gugu/b2d9dd70e5b2f7df2343d5fc1be4718f to your computer and use it in GitHub Desktop.
<?
$url = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$escaped_url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.short.cm/links");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"domain\": \"tuneup.fit\",
\"originalURL\": \"$url\",
\"path\": \"\",
\"title\": \"\"
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: yPsWQcKyOlRZVpia"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
echo '<input type="text" class="form-control" id="select-this"" value="' . $response . '">';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment