|
发表于 2020-3-1 00:49:56
|
显示全部楼层
- function makeShortUrl($url)
- {
- $url = urlencode($url);
- $result = @file_get_contents("https://v1.alapi.cn/api/url?url={$url}");
- if ($result){
- $result = json_decode($result, true);
- if (isset($result['data']['short_url'])){
- return $result['data']['short_url'];
- }
- }
- return false;
- }
-
- echo makeShortUrl('http://baidu.com');
复制代码
刚好用到,举手之劳 |
|