option('type'); $data = $this->option('data'); log_s('数据同步 => 开始发送:' . $type, 'sync', 'send'); log_s($data, 'sync-old', 'send'); try { $platform = Platform::first(); if (!$platform) { log_s('数据同步 => 发送结果:无平台数据', 'sync', 'send'); return Command::SUCCESS; } if ($platform->status != Platform::STATUS_PASS) { log_s('数据同步 => 发送结果:权限不足', 'sync', 'send'); return Command::SUCCESS; } $response = $this->newRequest()->post($platform->url_new, [ 'form_params' => [ 'platform_token' => $platform->token, 'type' => $type, 'data' => json_encode($data), ] ]); $contents = $response->getBody()->getContents(); $result = json_decode($contents, true); log_s('数据同步 => 发送结果:' . var_export($result, true), 'sync', 'send'); } catch (Exception $exception) { log_s('数据同步 => 错误信息:' . $exception->getMessage(), 'sync', 'send'); } return Command::SUCCESS; } public function newRequest(): Client { return new Client([ 'timeout' => 10, 'verify' => false, 'http_errors' => false, ]); } }