在网站跳转小程序(QQ/微信) 糖巴 2023-03-07 关注 私信 10 大家好,我是[玫瑰][滑稽]KongHen[滑稽][玫瑰] 今天在写一个页面的时候,需要用到跳转小程序,就查了一点资料,写了一个简单PHP例子, 提供需要的人看看这里是 QQ小程序 //网站跳转QQ小程序较简单,可能是用户较少,官方懒得维护更新吧 $url = ‘https://m.q.qq.com/a/p/这里填写小程序appid?s=这里填写页面路径&mode=wanba’; //跳转QQ小游戏(不涉及页面路径,a和b是参数,a=1&b=2) $url = ‘https://m.q.qq.com/a/p/这里填写小游戏appid?s=a=参数1&b=参数2’; 如图1 微信小程序 //微信小程序较麻烦,且生成的链接有效期为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; 如图2 下载地址 图片 ? 版权声明内容均来自互联网,如有侵权,请与我联系 本文链接:http://wu.shouluku.com/showinfo-18-18896-0.html THE END 网站源码 源码分享 网站源码分享 app源码下载 喜欢就支持以下吧 点赞 分享QQ空间微博QQ好友海报分享复制链接收藏2