短网址链接生成
Kate·Api 官方文档
长网址缩短服务,支持新浪、微信、腾讯短网址
基本说明:
接口地址:https://api.66mz8.com/api/short.php
返回格式:json
请求方式:get/post
请求示例:https://api.66mz8.com/api/short.php?dwz=wechat&url=https://wcccc.cc
请求参数说明:
名称 类型 必填 说明
url string 必填 需要缩短的网址
dwz string 选填 选择缩短接口 [wechat,urlcn,tcn,sinaurl,suoim,suonz,mrwso]
返回参数说明:
名称 类型 说明
code string 返回的状态码
msg string 返回提示信息
url_long string 缩短的源网址链接
url_short string 缩短的短网址链接
JSON返回示例:
{
    "code": 200,
    "msg": "success",
    "url_long": "https:\/\/wcccc.cc",
    "url_short": "https:\/\/w.url.cn\/s\/Ab3KnoH"
}
服务级错误码参照
错误码 说明
203 网址链接格式不正确
完整教学代码示例
<?php

/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2020/04/04 23:26
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://api.66mz8.com/api/short.php?dwz=wechat&url=https://wcccc.cc';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://api.66mz8.com/api/short.php?dwz=wechat&url=https://wcccc.cc"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}