<?php
$appId = ''; //这里填appid
$appsecret = ''; //这里填appsecret
$timestamp = time();
$jsapi_ticket = make_ticket($appId,$appsecret);
$nonceStr = make_nonceStr();
$url = 'http://222.178.203.72:19005/whst/63/'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$signature = make_signature($nonceStr,$timestamp,$jsapi_ticket,$url);
function make_nonceStr()
{
$codeSet = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
for ($i = 0; $i<16; $i++) {
$codes[$i] = $codeSet[mt_rand(0, strlen($codeSet)-1)];
}
$nonceStr = implode($codes);
return $nonceStr;
}
function make_signature($nonceStr,$timestamp,$jsapi_ticket,$url)
{
$tmpArr = array(
'noncestr' => $nonceStr,
'timestamp' => $timestamp,
'jsapi_ticket' => $jsapi_ticket,
'url' => $url
);
ksort($tmpArr, SORT_STRING);
$string1 = http_build_query( $tmpArr );
$string1 = urldecode( $string1 );
$signature = sha1( $string1 );
return $signature;
}
function make_ticket($appId,$appsecret)
{
// access_token 应该全局存储与更新,以下代码以写入到文件中做示例
$data = json_decode(file_get_contents("access_token.json"));
if ($data->expire_time < time()) {
$TOKEN_URL="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appId."&secret=".$appsecret;
$json = file_get_contents($TOKEN_URL);
$result = json_decode($json,true);
$access_token = $result['access_token'];
if ($access_token) {
$data->expire_time = time() + 7000;
$data->access_token = $access_token;
$fp = fopen("access_token.json", "w");
fwrite($fp, json_encode($data));
fclose($fp);
}
}else{
$access_token = $data->access_token;
}
// jsapi_ticket 应该全局存储与更新,以下代码以写入到文件中做示例
$data = json_decode(file_get_contents("jsapi_ticket.json"));
if ($data->expire_time < time()) {
$ticket_URL="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
$json = file_get_contents($ticket_URL);
$result = json_decode($json,true);
$ticket = $result['ticket'];
if ($ticket) {
$data->expire_time = time() + 7000;
$data->jsapi_ticket = $ticket;
$fp = fopen("jsapi_ticket.json", "w");
fwrite($fp, json_encode($data));
fclose($fp);
}
}else{
$ticket = $data->jsapi_ticket;
}
return $ticket;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>微信JS-SDK Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<link rel="stylesheet" href="style.css">
</head>
<body ontouchstart="">
<div class="wxapi_container">
<div class="wxapi_index_container">
<ul class="label_box lbox_close wxapi_index_list">
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-basic">基础接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-share">分享接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-image">图像接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-voice">音频接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-smart">智能接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-device">设备信息接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-location">地理位置接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-webview">界面操作接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-scan">微信扫一扫接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-shopping">微信小店接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-card">微信卡券接口</a></li>
<li class="label_item wxapi_index_item"><a class="label_inner" href="#menu-pay">微信支付接口</a></li>
</ul>
</div>
<div class="lbox_close wxapi_form">
<h3 id="menu-basic">基础接口</h3>
<span class="desc">判断当前客户端是否支持指定JS接口</span>
<button class="btn btn_primary" id="checkJsApi">checkJsApi</button>
<h3 id="menu-share">分享接口</h3>
<span class="desc">获取“分享到朋友圈”按钮点击状态及自定义分享内容接口</span>
<button class="btn btn_primary" id="onMenuShareTimeline">onMenuShareTimeline</button>
<span class="desc">获取“分享给朋友”按钮点击状态及自定义分享内容接口</span>
<button class="btn btn_primary" id="onMenuShareAppMessage">onMenuShareAppMessage</button>
<span class="desc">获取“分享到QQ”按钮点击状态及自定义分享内容接口</span>
<button class="btn btn_primary" id="onMenuShareQQ">onMenuShareQQ</button>
<span class="desc">获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口</span>
<button class="btn btn_primary" id="onMenuShareWeibo">onMenuShareWeibo</button>
<h3 id="menu-image">图像接口</h3>
<span class="desc">拍照或从手机相册中选图接口</span>
<button class="btn btn_primary" id="chooseImage">chooseImage</button>
<span class="desc">预览图片接口</span>
<button class="btn btn_primary" id="previewImage">previewImage</button>
<span class="desc">上传图片接口</span>
<button class="btn btn_primary" id="uploadImage">uploadImage</button>
<span class="desc">下载图片接口</span>
<button class="btn btn_primary" id="downloadImage">downloadImage</button>
<h3 id="menu-voice">音频接口</h3>
<span class="desc">开始录音接口</span>
<button class="btn btn_primary" id="startRecord">startRecord</button>
<span class="desc">停止录音接口</span>
<button class="btn btn_primary" id="stopRecord">stopRecord</button>
<span class="desc">播放语音接口</span>
<button class="btn btn_primary" id="playVoice">playVoice</button>
<span class="desc">暂停播放接口</span>
<button class="btn btn_primary" id="pauseVoice">pauseVoice</button>
<span class="desc">停止播放接口</span>
<button class="btn btn_primary" id="stopVoice">stopVoice</button>
<span class="desc">上传语音接口</span>
<button class="btn btn_primary" id="uploadVoice">uploadVoice</button>
<span class="desc">下载语音接口</span>
<button class="btn btn_primary" id="downloadVoice">downloadVoice</button>
<h3 id="menu-smart">智能接口</h3>
<span class="desc">识别音频并返回识别结果接口</span>
<button class="btn btn_primary" id="translateVoice">translateVoice</button>
<h3 id="menu-device">设备信息接口</h3>
<span class="desc">获取网络状态接口</span>
<button class="btn btn_primary" id="getNetworkType">getNetworkType</button>
<h3 id="menu-location">地理位置接口</h3>
<span class="desc">使用微信内置地图查看位置接口</span>
<button class="btn btn_primary" id="openLocation">openLocation</button>
<span class="desc">获取地理位置接口</span>
<button class="btn btn_primary" id="getLocation">getLocation</button>
<h3 id="menu-webview">界面操作接口</h3>
<span class="desc">隐藏右上角菜单接口</span>
<button class="btn btn_primary" id="hideOptionMenu">hideOptionMenu</button>
<span class="desc">显示右上角菜单接口</span>
<button class="btn btn_primary" id="showOptionMenu">showOptionMenu</button>
<span class="desc">关闭当前网页窗口接口</span>
<button class="btn btn_primary" id="closeWindow">closeWindow</button>
<span class="desc">批量隐藏功能按钮接口</span>
<button class="btn btn_primary" id="hideMenuItems">hideMenuItems</button>
<span class="desc">批量显示功能按钮接口</span>
<button class="btn btn_primary" id="showMenuItems">showMenuItems</button>
<span class="desc">隐藏所有非基础按钮接口</span>
<button class="btn btn_primary" i
Jsonkim
- 粉丝: 17
- 资源: 4
最新资源
- ACC自适应巡航的carsim与simulink联合仿真模型
- 儿童节烟花代码python实现
- 重庆邮电大学信号处理实验二报告
- 基于蒙特卡洛法的概率潮流 以IEEE33节点的电网为研究对象 建立了光伏和风电的概率出力模型 采用蒙特卡洛法进行随机抽样 之后基于抽样序列进行概率潮流计算 最后得到电网的电压概率出力曲线 程序有基
- SPI 接口作为slave的代码,Verilog编写注释详细,功能正确;
- python打包工具-windows一键打包运行
- 温度通信系统 LCD显示+上位机显示 传感器使用的是ds18b20,LCD显示温度,还可以串口通信在pc上显示温度,并且有VB的上位机程序,实时显示波形,实物验证成功 自己写的代码,注释详细 有代码有
- FocusAny v0.5.0 分离窗口快捷键,智能区域,工单使用支持 一个专注高效的AI工具条,可以使用 Alt / Option+空格 一键唤起,通过插件快速安装,可以扩展出非常多的功能
- 国产兼容三菱FX3U源码,最新一波bug修改,修改监控时卡顿问题 8位口令功能,程序消除功能,定时器特殊情况下不运行问题 带modbus-tcp功能,实时时钟,深度测试后,修改一些主要bug后,稳
- 爱乔(上海)医疗科技有限公司创投信息
- 电动汽车优化调度(分时电价调度) 软件:Matlab 介绍:首先利用蒙特卡洛模拟法模拟出电动汽车负荷曲线同时求解出无序充电功率曲线,作为有序充电曲线的对比基础,之后利用拉格朗日松弛算进行电动汽车优化调
- 北京慧夜科技有限公司创投信息
- 基于粒子群优化随机森林(PSO-RF)的数据回归预测 matlab代码
- 信号处理实验报告2-7.7z
- 高速铁路环境的时分-长期演进(TD-LTE)系统A3事件触发切算法的优化 通过对常规的A3事件切判决准则的研究,提供基于用户终端(UE)速度的A3事件触发切判决准则的算法 介绍时分-长期演进(TD
- 北京探马企服科技有限公司创投信息
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈