data = $data; } /** * Execute the job. * * @return void */ public function handle() { file_put_contents('record2.txt',json_encode($this->data) .PHP_EOL,8); //数据要发送的地址 $url = ClearDataService::getUrl($this->data); $return = $this->sendRequest($url,$this->data); // file_put_contents('send.txt',json_encode($return) .PHP_EOL,8); //输出信息 测试 $this->echoMessage(new ConsoleOutput()); } private function sendRequest($url,$data){ $data = json_encode($data); $header[] = "Content-Type:application/json"; $ch=curl_init($url); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $response=curl_exec($ch); $response=json_decode($response,true); if(curl_errno($ch) ){ sc(curl_error($ch)); } return $response; } protected function echoMessage(OutputInterface $output) { $output->writeln('2222222'); } }