Home > Article > Backend Development > PHP uses curl to simulate post request to submit xml
PHP uses curl to simulate post request submission xml (the request is the interface on the Java server) But using httprequest to request in jsp can be successful Post data is processed in this way in JAVA. Similarly, I still can’t solve it after using asXML() in PHP Element r=rootEle.element("hmac"); r.setText(signMessage); result.put("xml",xml); Document.setXMLEncoding("GBK"); System.out.println("Complete xml request message:"+document.asXML()); Below is php Public function test(){ $testHost = 'http://127.0.0.1:8080' $data=' echo ($response); } protected function sendPost($url,$data){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } |