appId = $appId; $this->apiKey = $apiKey; $this->apiSecret = $apiSecret; $this->uid = $uid; $this->resId = $resId; $this->requestConfig = new TcConfig($requestConfig); $this->client = new HttpClient([]); } public function request($text) { $uri = self::signUriV1(TcConstants::URI, [ 'apiKey' => $this->apiKey, 'apiSecret' => $this->apiSecret, 'host' => TcConstants::HOST, 'requestLine' => TcConstants::REQUEST_LINE ]); $body = self::generateInput($text, $this->appId, $this->uid, $this->resId, $this->requestConfig->toArray()); return $this->client->sendAndReceive( new Request( 'POST', $uri, ['Content-Type' => 'application/json;charset=UTF-8'], $body ) ); } public function listUpload($whiteList, $blackList) { if (empty($this->uid) || empty($this->resId)) { return false; } $response = $this->client->sendAndReceive( new Request( 'POST', TcConstants::LIST_UPLOAD_URI, ['Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'], self::jsonEncode([ 'common' => [ 'app_id' => $this->appId, 'uid' => $this->uid, ], 'business' => [ 'res_id' => $this->resId ], 'data' => base64_encode(self::jsonEncode([ 'white_list' => $whiteList, 'black_list' => $blackList ])) ]) ) ); $content = json_decode($response->getBody()->getContents(), true); return $content['message'] == 'success'; } }