request('GET', self::BASE_URL.'v1/activities/'.$channelId, [ 'headers' => [ 'Authorization' => self::TOKEN ] ]); $info = json_decode((string)$res->getBody(),true); if ($channelName !== $info['name']) { throw new ApiException("频道名称不一致,频道{$channelId}名称为 ".$info['name']); } } public function setAuthUrl(int $channelId, string $redirectUrl) { $client = new Client(); $res =$client->request('Post', self::BASE_URL.'v1/activities/'.$channelId.'/setAuth', [ 'headers' => [ 'Authorization' => self::TOKEN ], 'json' => [ 'method' => 'CUSTOM_VERIFY', 'redirect_url' => $redirectUrl ] ]); $info = json_decode((string)$res->getBody(),true); if ($info['status'] !== 'y') { throw new ApiException("设置自定义授权url失败--".(string)$res->getBody()); } } public function getAuthCode(int $channelId) { $client = new Client(); $res =$client->request('Post', self::BASE_URL.'v1/activities/'.$channelId.'/getAuthKey', [ 'headers' => [ 'Authorization' => self::TOKEN ] ]); $info = json_decode((string)$res->getBody(),true); if (empty($info)){ throw new ApiException($info['message']); } return $info['authkey']; } }