/**
* 获取jssdk签名
*/
public function signature(Request $request){
//随机字符串
$str = time() . rand(111111,999999). 'suibian';
$nonce_str = substr( md5($str),5,8 );
$timestamp = time(); //当前时间戳
$url = $request['url']; //需要前端传过来
$data = [
'jsapi_ticket' => '文档有',
'noncestr' => $nonce_str,
'timestamp' => $timestamp,
'url' => $url
];
$param = "";
foreach($data as $k=>$v){
$param .= $k.'='.$v.'&';
}
$p = rtrim($param,'&');
//计算签名
$signature = sha1($p);
$response['nonce_str'] = $nonce_str;
$response['timestamp'] = $timestamp;
$response['signature'] = $signature;
$response['url'] = $url;
echo json_encode($response);
}
Code de génération de signature WeChat jssdk
Je suppose que tu aimes
Origine blog.csdn.net/weixin_44900765/article/details/106352147
conseillé
Classement