array_column1($phone_data, "phone"); $wx_data['IMEI']=$device_code; $wx_data['phone']=$openids; $wx_data['evt']=$alarm_type; $wx_data['time']=$time; $wx_data['insert_id']=$Res; $wx_data['bz']=''; $wx_data['user_from']='water_form'; $wx_data['Status']=$alarm_type; if ($res_owner[0]['dwtype']==2){ $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Waterwarn/message_water"; }else{ $url = "https://iot.usky.cn/jdxf/wxapp2.php/Home/Yeweiwarn/message_water"; } Log::record('yangpu4GWxUrl'.':'.$url); Log::record('yangpu4GWxData'.':'.json_encode($wx_data, JSON_FORCE_OBJECT)); $res = $this->curl($url,$wx_data); print_r($res); } $returnInformation['code'] = true; $returnInformation['msg'] = "成功"; return json_encode($returnInformation); } public function array_column1($rows, $column_key, $index_key = null) { $data = array(); if (empty($index_key)) { foreach ($rows as $row) { $data[] = $row[$column_key]; } $data=implode(",",$data); } else { foreach ($rows as $row) { $data[$row[$index_key]] = $row[$column_key]; } } return $data; } public function curl($url,$data=''){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $info = curl_exec($ch); if (curl_errno($ch)) { $info = 'ERROR: ' . curl_error($ch); } curl_close($ch); return $info; } }