tinyurl
TinyURL is an awesome service. For those who don't know what TinyURL is, TinyURL allows you to take a long URL like "https://davidwalsh.name/jquery-link-nudging" and turn it into "http://tinyurl.com/67c4se". Using the PHP and TinyURL API, you can create these tiny URLs on the fly!
TinyURL是一项很棒的服务。 对于那些不知道TinyURL是什么的人,TinyURL允许您采用长网址,例如“ https://davidwalsh.name/jquery-link-nudging”,并将其转换为“ http://tinyurl.com/67c4se” 。 使用PHP和TinyURL API,您可以即时创建这些微小的URL!
PHP (The PHP)
//gets the data from a URL
function get_tiny_url($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$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('https://davidwalsh.name/php-imdb-information-grabber');
//returns http://tinyurl.com/65gqpp
echo $new_url
Simply provide the URL and you'll received the new, tiny URL in return. If you use Twitter, you'll have noticed that Twitter automates tiny URL creation for URLs in tweets.
只需提供URL,您就会收到新的微小URL作为回报。 如果您使用Twitter,您会注意到Twitter自动为推文中的URL自动创建微小的URL。
tinyurl