1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public function login() { $random = md5(rand());
$this->session->set_userdata([ 'csrf_token' => $random, ]);
$url = 'https://open.weixin.qq.com/connect/qrconnect?' . http_build_query([ 'appid' => $this->config['oauth']['wechat']['appid'], 'redirect_uri' => $this->config['oauth']['wechat']['redirect_uris'], 'response_type' => 'code', 'scope' => 'snsapi_login', 'state' => $random, // 防止 CSRF 攻擊 ]) . '#wechat_redirect';
redirect($url); }
|