Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- - Shorten URL (tinyurl)
- - Sends a request to tinyurl's API via cURL to shorten the specified URL
- - Returns the resulting short URL
- $link - The http URL to shorten
- $timeout - How many seconds to wait before giving up
- */
- public function tinyUrl($link, $timeout = 5) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://tinyurl.com/api-create.php?url=" . $link);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
Add Comment
Please, Sign In to add comment