小程序短链

接口说明

快速生成微信小程序短链接,支持微信外一键打开小程序,跳转至微信小程序指定页面。

接口地址

https://c1n.cn/link/miniProgram

请求方式

POST

请求头:Headers

请求参数:Form 表单

响应数据:JSON格式

{
    code: 0,
    data: "https://c1n.cn/xxxxx",
    msg: "成功
}
//说明:code为0表示成功,其他情况表示生成失败。

SDK DEMO

<?php
function short_url($app_id, $path, $secret)
{
    $headers = [
        'Content-Type: application/x-www-form-urlencoded',
        'token: your_token'  // 替换为您的token
    ];
    $data = [
        'appId' => $app_id,
        'path' => $path,
        'secret' => $secret,
        'remark' => '',
        'expiryDate' => '',
        'domainName' => ''
    ];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://c1n.cn/link/miniProgram');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    $response_data = json_decode($response, true);
    if ($response_data['code'] == 0) {
        return $response_data['data'];
    }
    echo $response_data['msg'];
}
// 请确保您的PHP环境中已经安装了cURL库
$res = short_url('xxxx','xxxx','');  // 替换为您自己的小程序信息
echo $res; 
?>