Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Js.php文件的获取当前的url建议调整为\Yii::$app->request->absoluteUrl #10

Open
dungang opened this issue Apr 12, 2019 · 3 comments

Comments

@dungang
Copy link

dungang commented Apr 12, 2019

当我使用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;
    }
@abei2017
Copy link
Owner

感谢提交,我测试下。

@dungang
Copy link
Author

dungang commented Apr 29, 2019

有结果了吗?

@flashjay
Copy link

flashjay commented May 9, 2020

Url::current([],true)! 确实有问题
ps:直觉项目已亡,也不记得为什么用这个,可能是比较轻量吧。@dungang 换别的吧,或者自己写一个。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants