PHP 简单调用rest WebServices

 1 <?php
 2 $ch = curl_init("http://api.cachk.com:8185/Tech-Trans.esPOS4.PosService.UAT/rest/enquiryv40/getvipbonus/");
 3 $post_data = array(
 4     'apikey' => '00F4886493925256BEA7E5C6E4D704',
 5     'vipCode' => '80117088'
 6 );
 7 $data_string =  json_encode($post_data);
 8 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
 9 curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
10 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
11 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
12     'Content-Type: application/json',
13     'Content-Length: ' . strlen($data_string)
14 ));
15  
16 $output = curl_exec($ch);
17  
18 curl_close($ch);
19 echo  $output;exit;
20 ?>

 

posted on 2018-01-10 14:32  我就要超鬼  阅读(202)  评论(0编辑  收藏  举报

导航