小程序短链接
链接无缝跳转小程序

快速生成微信小程序短链接,支持微信外一键打开小程序,跳转至微信小程序指定页面。
https://c1n.cn/link/miniProgramPOST
{
code: 0,
data: "https://c1n.cn/xxxxx",
msg: "成功
}
//说明:code为0表示成功,其他情况表示生成失败。
<?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;
?>