前提条件:有一个完成认证非个人的微信小程序,小程序有一个页面contactus有一个你的微信二维码图片,例如地址是/pages/contactus/contactus。
1、通过后端代码生成微信小程序的url-scheme链接,类似于这样的:weixin://dl/business/?t= *TICKET*,生成这个url-scheme链接的代码在最后面:
2、用url-scheme链接做一个跳转的h5网页
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
<title>加我我好友</title>
<style>
body{
text-align: center;
padding-top: 200px;
}
</style>
</head>
<body>
<a href="weixin://dl/business/?t=TICKET">加我我好友</a>
</body>
</html>2、把这个网页放到web服务器上,然后在抖音中发送包含链接跳转的h5网页地址即可
参考:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateScheme.html
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html
最后奉上php生成微信小程序url-scheme链接的代码
点击查看全文
<?php
function curlPost($url, $data, $method = "POST") {
$ch = curl_init(); //1.初始化
curl_setopt($ch, CURLOPT_URL, $url); //2.请求地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //3.请求方式
//4.参数如下
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //https
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); //模拟浏览器
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Encoding: gzip, deflate')); //gzip解压内容
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
if ($method == "POST") {
//5.post方式的时候添加数据
$data = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch); //6.执行
if (curl_errno($ch)) {
//7.如果出错
return curl_error($ch);
}
curl_close($ch); //8.关闭
return $tmpInfo;
}
$appid = "";
$appsecret = "";
//path是要跳转的小程序页面地址,query为要携带的参数,通过 URL Scheme 打开小程序的场景值为 1065。
$body = ['jump_wxa' => ['path' => '/pages/contactus/contactus',
'query' => 'fromsource=1']];
$tokenurl = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $appsecret;
$data = file_get_contents($tokenurl);
$data = json_decode($data, true);
$token = $data['access_token'];
$url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=" . $token;
$data = curlPost($url, $body);
$linkdata=json_decode($data,true);
echo $linkdata['openlink'];
var_dump($data); 网友回复
如何破解绕开seedance2.0真人照片生成视频 限制?
python有哪些算法可以将视频中的每个帧图片去除指定区域水印合成新的视频?
iphone的激光雷达数据能否实时传输到three三维空间中?
豆包sora等ai视频生成大模型生成的视频水印如何去除?
python如何实现在电脑上拨号打电话给手机?
具身机器人与人形机器人区别?
nodejs如何将一个完整的js代码文件切割成不同的部分混淆后动态加载进入html运行?
为啥windows.onerror捕获js错误是这样的{"message":"Script error.","source":"","lineno":0,"colno":0,"stack":null,
2026年ai将全面接管编程?
WebMCP是干啥的?


