header = [ 'time_string:' . $time_string, ]; } /** * 发送http post请求 * @param string $url 请求地址 * @param array $headers 请求头 * @param json $postdata 请求数据 * @param array $options curl配置项 */ public static function curl_post($url = '', $headers = '', $postdata = '', $options = array()) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } if (!empty($options)) { curl_setopt_array($ch, $options); } $data = curl_exec($ch); return $data; } /** * 发送http get请求 */ public static function curl_get($url = '', $headers = '', $options = array()) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 5); if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } if (!empty($options)) { curl_setopt_array($ch, $options); } $data = curl_exec($ch); return $data; } /** * 提交设备采样数据接口 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function submitDeviceData($request_data) { $url = $this->baseUrl . '/report/submitReport'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 获取报告接口 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function getReport($request_data) { $url = $this->baseUrl . '/report/getReport'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 获取报告18大风险对应的商品推荐 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function getDeviceData($request_data) { $url = $this->baseUrl . '/report/getRiskCommodityList'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 体质卡兑换 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function exchangeHealthCard($request_data) { $url = $this->baseUrl . '/physiqueCard/exchangePhysiqueCard'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 获取近两天报告 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function getTwoDayReport($request_data) { $url = $this->baseUrl . '/report/getDaysReportsList'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 获取近一周报告 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function getOneWeekReport($request_data) { $url = $this->baseUrl . '/report/getWeeksReportsList'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 两笔报告对比 * @author 唐远望 * @version 1.0 * @date 2026-01-06 */ public function compareTwoReport($request_data) { $url = $this->baseUrl . '/report/getReportContrast'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 激活设备 * @author 唐远望 * @version 1.0 * @date 2026-01-08 */ public function activateDevice($request_data){ $url = $this->baseUrl . '/report/activateCode'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } /** * 获取设备信息 * @author 唐远望 * @version 1.0 * @date 2026-01-08 */ public function getDeviceInfo($request_data){ $url = $this->baseUrl . '/report/getDeviceInfo'; $response = self::curl_post($url, $this->header, json_encode($request_data)); $response_data = json_decode($response, true); return $response_data; } }