Created
September 20, 2014 03:51
-
-
Save greymeister/98c1895d94017b079280 to your computer and use it in GitHub Desktop.
emoji.xyz URL shortener (I use ;smoji)
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
#!/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