Return to Snippet

Revision: 11620
at February 11, 2009 11:50 by nerdsane


Initial Code
//gets the data from a URL  
function get_tiny_url($url)  
{  
	$ch = curl_init();  
	$timeout = 5;  
	curl_setopt($ch,CURLOPT_URL,'http://href.in/api.php?create='.$url);  
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
	$data = curl_exec($ch);  
	curl_close($ch);  
	return $data;  
}

//test it out!
$new_url = get_tiny_url('http://twitter.com/inerds');

//returns http://href.in/gh7uab
echo $new_url

Initial URL
http://href.in/api_example.php

Initial Description
To use href.in API to generate a short URL.  using php curl

Initial Title
Create href.in short urls

Initial Tags
curl, php

Initial Language
PHP