_data = $data; } /** * 设置参数 * @param $data */ public function setData($data) { foreach ($data as $k => $v) { $this->_data[$k] = $v; } } /** * 岗位信息库提交 */ public function jobInfo() { $this->_log_name = '同步岗位给妇联'; $url = self::BASE_URL . '/getJob.html'; $res = $this->_send($url); return $res; } /** * 岗位信息库提交 */ public function jobInfos() { $this->_log_name = '同步岗位列表给妇联'; $url = self::BASE_URL . '/getJobs.html'; $res = $this->_send($url); return $res; } /** * 发送数据 * @param $url * @return mixed */ private function _send($url) { Log::info($this->_log_name . ':' . json_encode($this->_data)); //请求头 $header = [ 'Content-Type: application/json', ]; //发送数据 $response = http_request($url, 'POST', json_encode($this->_data), $header); Log::info($this->_log_name . '返回数据:' . $response); //重置默认值,方便下一次使用 $this->_data = []; $this->_log_name = ''; return json_decode($response,true); } }