public function actionBindWechat() { //validate if the count of the channel has exceeded the limitation $limit = $this->_getChannelLimit(); $accountId = $this->getAccountId(); $channelCount = Channel::getEnableCountByAccountId($accountId); if ($channelCount >= $limit) { throw new BadRequestHttpException(Yii::t('channel', 'channel_count_limit')); } $component = Yii::$app->weConnect->getComponentToken(); $componentToken = $component['componentToken']; $componentAppId = $component['componentAppId']; // $componentToken = "abc123123123"; // $componentAppId = "wx3930d6279611b5c5"; $accessToken = $this->getAccessToken(); $redirectUrl = Yii::$app->request->hostInfo . '/api/management/channel/create-wechat'; $redirectUrl = urlencode($redirectUrl); //get pre auth code $preCode = Yii::$app->weConnect->getPreauthcode($componentToken, $componentAppId); return ["bindPath" => "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$componentAppId}&pre_auth_code={$preCode}&redirect_uri={$redirectUrl}&componenttoken={$componentToken}"]; }