yii2-wx
yii2-wx copied to clipboard
Js.php文件的获取当前的url建议调整为\Yii::$app->request->absoluteUrl
当我使用urlrule 美化的时候导致浏览器的地址和这里的地址不一致,从而签名失败
/**
* 获得jssdk需要的配置参数
* 这里包含appId、nonceStr、timestamp、url和signature。
*
* @return array
*/
public function signature(){
$url = Url::current([],true); // 建议替换为 **\Yii::$app->request->absoluteUrl**
$nonce = Yii::$app->security->generateRandomString(32);
$timestamp = time();
$ticket = $this->ticket();
$sign = [
'appId' => $this->conf['app_id'],
'nonceStr' => $nonce,
'timestamp' => $timestamp,
'signature' => $this->getSignature($ticket, $nonce, $timestamp, $url),
];
return $sign;
}
感谢提交,我测试下。
有结果了吗?
Url::current([],true)! 确实有问题 ps:直觉项目已亡,也不记得为什么用这个,可能是比较轻量吧。@dungang 换别的吧,或者自己写一个。