1.网站跳转QQ小程序

$url = 'https://m.q.qq.com/a/p/这里填写小程序appid?s=这里填写页面路径&mode=wanba';

2.跳转QQ小游戏(不涉及页面路径,a和b是参数,a=1&b=2)

$url = 'https://m.q.qq.com/a/p/这里填写小游戏appid?s=a=参数1&b=参数2';

3.微信小程序较麻烦,且生成的链接有效期为30天,且每个链接只能点击一次,所以,每次用都要重新生成一次,好在每天都能生成50万条,不用担心数量限制。

$token = file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=这里是appid&secret=这里是appsecert');
$token = json_decode($token, true);
$token = $token["access_token"];
$url='https://api.weixin.qq.com/wxa/generatescheme?access_token='.$token;
$options = array(
'http' => array(
'method' => 'POST',
'jump_wxa'=> '{
"path": "",//这里是小程序的页面路径,注意,不可以是tabber页面,空的时候就跳转首页
"query": ""
}',
),
);
$result = file_get_contents($url, false, stream_context_create($options));
$link = json_decode($result, true)["openlink"];
//这个link就是最终生成的链接
$link = 'https://servicewechat.com/wxascheme/jump_wxa?url='.$link;
最后修改:2023 年 03 月 07 日
如果觉得我的文章对你有用,请随意赞赏