data = $data; parent::__construct(); // 调用父类的构造函数 } /** * Execute the job. * * @return void */ public function handle() { $url = ''; $return = $this->sendRequest($url,$this->data); file_put_contents('charge.txt',json_encode($this->data),8); $this->echoMessage(new ConsoleOutput()); } private function sendRequest($url,$data){return true; $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); file_put_contents('job_send.txt',$response.PHP_EOL,8); $response=json_decode($response,true); if(curl_errno($ch) ){ sc(curl_error($ch)); } return $response; } protected function echoMessage(OutputInterface $output) { $output->writeln('2222222'); } protected function execute(InputInterface $input, OutputInterface $output) { $output->write('22222222'); $output->writeln('2222222'); } }