Skip to content

Instantly share code, notes, and snippets.

@greymeister
Created September 20, 2014 03:51
Show Gist options
  • Save greymeister/98c1895d94017b079280 to your computer and use it in GitHub Desktop.
Save greymeister/98c1895d94017b079280 to your computer and use it in GitHub Desktop.
emoji.xyz URL shortener (I use ;smoji)
#!/usr/bin/php
<?php
// Request: Local emoji-web (http://emoji.xyz/shorten)
$ch = curl_init("http://emoji.xyz/shorten");
curl_setopt($ch, CURLOPT_POST, TRUE);
// Headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
));
// Body
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"url\":\"%clipboard\"}");
// Send synchronously
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
// Failure
if ($result === FALSE)
{
echo "cURL Error: " . curl_error($ch);
}
// Success
else
{
//echo "Request completed: " . $result;
$result = json_decode($result);
echo $result->{'url'};
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment