'huanxiao.zhang@kuxuan-inc.com', 'password' => 'VVrKdPqTSiMa8WaW', 'adminType' => 1 ], [ 'loginAccount' => 'chuanxiao.zhang@kuxuan-inc.com', 'password' => 'aRBtBFDIsbXlCEP1', 'adminType' => 1 ], [ 'loginAccount' => '941722557@qq.com', 'password' => 'HZjyx@0725', 'adminType' => 1 ] ]; /* * 调用接口取得凭证 * */ public static function getAccessToken($accountLabel=0) { $accessToken = RedisModel::get(self::ACCESS_TOKEN_RDS_KEY . '_' .$accountLabel); if(empty($accessToken)) { $accessToken = self::login($accountLabel); } return $accessToken; } /** * 获取登录凭证 * @param * */ public static function login($accountLabel, $retry = 0) { $requestUri = self::BASE_URI . self::LOGIN_URI; $accountInfo = YouZiService::ACCOUNT_LIST; $loginAccount = isset($accountInfo[$accountLabel]) ? $accountInfo[$accountLabel] : ''; if(empty($loginAccount)) return ''; # 获取响应数据 $accessToken = ''; $response = HttpService::httpPost($requestUri, json_encode($loginAccount), true); $responseData = json_decode($response, true); if(isset($responseData['code']) && $responseData['code'] == 0) { $accessToken = isset($responseData['data']['accessToken']) ? $responseData['data']['accessToken'] : ''; if(empty($accessToken) && $retry <5) { $retry++; return self::login($accountLabel, $retry); } if(!empty($accessToken)) RedisModel::set(self::ACCESS_TOKEN_RDS_KEY . '_' .$accountLabel, $accessToken); } if(empty($accessToken)) { Log::logError('接口调用凭证获取失败', [ 'label' => $accountLabel, 'retry' => $retry ], 'YouZiAccessToken'); } return $accessToken; } }