123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- //设置utf-8格式,解决中文乱码
- header("Content-type: text/html; charset=utf-8");
- date_default_timezone_set("PRC");
- // $WorkerCode = 'hg001';
- // $WorkerName = '护工001';
- // $txm = '1232345634P';
- // $NurseConfirmCode = '192.1.1.21';
- $reqMsg = $_POST['reqMsg'];
- try{
- $url = "http://127.0.0.1:8082";
- $ret = curl_post($url,['data' => $reqMsg]);
- $json = json_decode($ret,true);
- if(!empty($json) && $json['success']){
- return_ok('成功',$json['data']);
- }else{
- return_wrong('请求失败');
- }
- }catch (Exception $e){
- return_wrong('请求失败'.$e->getMessage());
- }
- function curl_post($url, $data) {
- $ch = curl_init ();
- $header = array ("Accept-Charset: utf-8",'Expect:' );
- 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_HTTPHEADER, $header );
- 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_TIMEOUT, 60 );
- // 最好加上http_build_query 转换,防止有些服务器不兼容
- curl_setopt ( $ch, CURLOPT_POSTFIELDS, http_build_query ( $data ) );
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
- $result = curl_exec ( $ch );
- curl_close ( $ch );
- return $result;
- }
- function xmltoarr($str){
- return json_decode(json_encode(simplexml_load_string($str, null, LIBXML_NOCDATA)),true);
- }
- function return_ok($msg = '成功',$data = ''){
- header('Content-Type:application/json; charset=utf-8');
- $result['status'] = 1;
- $result['msg'] = $msg ;
- $result['data'] = $data;
- exit(json_encode($result,JSON_UNESCAPED_UNICODE));
- }
- function return_wrong($msg = '失败'){
- header('Content-Type:application/json; charset=utf-8');
- $result['status'] = 0;
- $result['msg'] = $msg ;
- exit(json_encode($result,JSON_UNESCAPED_UNICODE));
- }
-
- ?>
|