|
|
|
@ -71,26 +71,28 @@ class WechatService extends BaseService |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param $url |
|
|
|
* @return array |
|
|
|
* @throws FuncException |
|
|
|
*/ |
|
|
|
public function getJsSdkSignature(): array |
|
|
|
public function getJsSdkSignature($url): array |
|
|
|
{ |
|
|
|
$url = 'https://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
|
|
|
|
|
|
|
$timestamp = time(); |
|
|
|
|
|
|
|
$nonceStr = generate_random_string(10); |
|
|
|
$nonceStr = generate_random_string(16); |
|
|
|
|
|
|
|
$jsapi_ticket = $this->getJsApiTicket(); |
|
|
|
|
|
|
|
$str = sprintf('jsapi_ticket=%s&noncestr=%s×tamp=%s&url=%s', $jsapi_ticket, $nonceStr, $timestamp, $url); |
|
|
|
$str = "jsapi_ticket={$jsapi_ticket}&noncestr={$nonceStr}×tamp={$timestamp}&url={$url}"; |
|
|
|
$signature = sha1($str); |
|
|
|
|
|
|
|
return [ |
|
|
|
'appId' => env('wechat.appid'), |
|
|
|
'timestamp' => $timestamp, |
|
|
|
'nonceStr' => $nonceStr, |
|
|
|
'signature' => $signature |
|
|
|
'signature' => $signature, |
|
|
|
'url ' => $url |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
@ -116,7 +118,7 @@ class WechatService extends BaseService |
|
|
|
throw new FuncException($res['msg']); |
|
|
|
} |
|
|
|
|
|
|
|
$data = json_decode($res['data'],true); |
|
|
|
$data = json_decode($res['data'], true); |
|
|
|
|
|
|
|
if (isset($data['errcode']) && $data['errcode'] != 0) { |
|
|
|
throw new FuncException($data['errmsg']); |
|
|
|
|