://u.nu/jy0a_使用U.Nu创建短URL

://u.nu/jy0a

I was recently referred to another URL shortening website called u.nu. As far as shortening services go, u.nu seems to have the field beat as far as the shortest base URL. If you're really intent on creating the shortest possible URLs, look no further than u.nu's API.

最近,我被引荐到另一个网址缩短网站u.nu。 就缩短服务而言,u.nu似乎已经击败了最短的基本URL。 如果您真的想创建尽可能短的URL,请只使用u.nu的API。

PHP (The PHP)


	function get_unu_url($url)
	{
		$url = 'http://u.nu/unu-api-simple?url='.urlencode($url);
		$ch = curl_init();  
		$timeout = 5;  
		curl_setopt($ch,CURLOPT_URL,$url);  
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
		$url = curl_exec($ch);  
		curl_close($ch);
		return trim($url);
	}
	
	$short_url = get_unu_url('https://davidwalsh.name');
	//returns http://u.nu/92e


That's it. I love that there's no XML or JSON involved with their API. What's returned is the URL and nothing more!

而已。 我喜欢他们的API不涉及XML或JSON。 返回的是URL,仅此而已!

翻译自: https://davidwalsh.name/create-short-urls-unu

://u.nu/jy0a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值