public function post_data($url,$data){
    $ch = curl_init();      
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($ch, CURLOPT_URL, $url); // 要访问的地址    
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30 ); //超时断开时间    
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);   //POST的数据
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //是否接收返回数据
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data)) );//网页头文件                                                                                                                 
     $result = curl_exec($ch);
     echo  $result;
    }

 

 

接收页面

$raw_post_data = file_get_contents('php://input', 'r');

需要再将数据进行处理;最好在传输页面将数据json_encode这边在json_decode就行了

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2022-02-17
  • 2021-12-15
  • 2022-01-14
  • 2022-03-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-03-31
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
相关资源
相似解决方案