前言
今天在写一个页面的时候,需要用到跳转小程序,就查了一点资料,写了一个简单PHP例子,提供需要的人看看这里下面
1、网站跳转QQ小程序代码
隐藏内容
评论可见
前往评论
可能用户比较少,官方懒得更新了
2、网站跳转QQ游戏小程序代码
[CommentView]
$url = 'https://m.q.qq.com/a/p/这里填写小游戏appid?s=a=参数1&b=参数2';
[/CommentView]
跳转QQ小游戏(不涉及页面路径,a和b是参数,a=1&b=2)
3、网站跳转微信小程序代码
[CommentView]
$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;
[/CommentView]
小程序较麻烦,且生成的链接有效期为30天,且每个链接只能点击一次,所以,每次用都要重新生成一次,好在每天都能生成50万条,不用担心数量限制
发表评论