2020最新腾讯短网址生成api接口推荐

腾讯短网址(url.cn)就是使用腾讯的API接口将冗长的链接转换成超短的url.cn链接。使用url.cn短网址更易于用户记忆,利于用户转化。

url短链接最开始是为了对抗http://t.cn推出的网址压缩服务,后来其微博倒闭,官方并没有停止http://url.cn的解析,但也没有对外开放接口。

使用说明

接口地址:http://api.monkeyapi.com
请求方式:http get/post
返回格式:json
请求示例:http://api.monkeyapi.com?appkey={appkey}&url=www.baidu.com

JSON返回示例

{
“code”: 200,
“msg”: “成功”,
“data”: “https://url.cn/46knc3k”
}

php示例

$url = “http://api.monkeyapi.com”;
$params = array(
‘appkey’ =>‘appkey’,//您申请的APPKEY
‘url’ =>‘www.monkeyapi.com’,//需要查询的网站
);

p a r a m s t r i n g = h t t p b u i l d q u e r y ( paramstring = http_build_query( paramstring=httpbuildquery(params);
c o n t e n t = C u r l ( content = Curl( content=Curl(url, $paramstring);
r e s u l t = j s o n d e c o d e ( result = json_decode( result=jsondecode(content, true);
if(KaTeX parse error: Expected '}', got 'EOF' at end of input: …{ var_dump(result);
}else {
//请求异常
}

//想详细了解可以加+V mkapi002

/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int i p o s t [ 是 否 采 用 P O S T 形 式 ] ∗ @ r e t u r n s t r i n g ∗ / f u n c t i o n C u r l ( ipost [是否采用POST形式] * @return string */ function Curl( ipost[POST]@returnstring/functionCurl(url, $params = false, $ispost = 0)
{
$httpInfo = array();
$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if ($ispost) {
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    curl_setopt($ch, CURLOPT_URL, $url);
}else {
    if ($params) {
        curl_setopt($ch, CURLOPT_URL, $url.'?'.$params);
    } else {
        curl_setopt($ch, CURLOPT_URL, $url);
    }
}

$response = curl_exec($ch);
    if ($response === FALSE) {
    //echo "cURL Error: " . curl_error($ch);
    return false;
}

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
curl_close($ch);
return $response;

}

常见问题

1、猴子数据接口稳定吗?

答:猴子数据采用官方接口实时返回,准确率高,支持大并发,稳定率99.999%。

2、什么请求量?

答:用户通过程序请求接口地址一次,接口返回一个结果(短链接)的过程叫做一次请求,需要请求短链接的次数叫做请求量。

3、请求频率是什么意思?

答:请求频率就是请求检测第一个短链接后再次请求第二个短链接时需要等待的时间。比如:频率2秒,就是两次请求直接必须间隔2秒。建议用户链接较多时使用不限频率接口,实时循环请求检测。

4、短链接接口可以批量请求吗?

答:猴子数据短链接api接口支持批量实时检测,用户可以通过定时脚本循环实时批量请求。

你可能感兴趣的:(移动开发)