Skip to content

Instantly share code, notes, and snippets.

@mathieu-aubin
Created February 13, 2016 04:40
Show Gist options
  • Save mathieu-aubin/b59e768aa085fcc7048a to your computer and use it in GitHub Desktop.
Save mathieu-aubin/b59e768aa085fcc7048a to your computer and use it in GitHub Desktop.
tinyurl.com API
<?php
function tinyUrl($url) {
$handle = curl_init();
$timeout = 5;
curl_setopt($handle,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($handle,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($handle);
curl_close($handle);
return $data;
}
$new_url = tinyUrl('http://zeroserieux.com');
echo $new_url;
@mathieu-aubin
Copy link
Author

there could be easy simple error handling..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment