This article to introduce a PHP Curl simulation post submission XML data, because the recipient only accept XML data so I wrote a, the following share to you friends, there is a need for friends to refer to.
The code is as follows |
Copy Code |
$url = "Http://www.bkjia.com/login"; $ch = Curl_init (); $header [] = "content-type:text/xml";//define Content-type as XML curl_setopt ($ch, Curlopt_url, $url); Define form submission Address curl_setopt ($ch, Curlopt_post, 1); Define the commit type 1:post; 0:get curl_setopt ($ch, Curlopt_header, 1); Defines whether to display status Header 1: display; 0: Do not display curl_setopt ($ch, Curlopt_httpheader, $header);//define Request type curl_setopt ($ch, Curlopt_returntransfer, 0);//defines whether direct output returns a stream curl_setopt ($ch, Curlopt_postfields, $data); Define the submitted data, here is the XML file Curl_close ($ch);//Close
|
Let's introduce a case of a post form submission
The code is as follows |
Copy Code |
The first thing to do is refer to this class Include ("/data/tools/pooy/snoopy/snoopy.class.php"); $snoopy = new Snoopy; $Parameters this is the array to commit $Parameters ["username"] = "user"; $Parameters ["pass"] = "pass"; $file = "/test/test.jpg"; $SERVICEURL = "http://www.test.com/fileProcess.php"; $postfiles ["image"] = $file; $filename upload file relative path such as "upload/taoav.jpg"; image/jpg $snoopy->_submit_type = "Multipart/form-data"; Set Submit Type $snoopy->submit ($SERVICEURL, $Parameters, $postfiles); |
http://www.bkjia.com/PHPjc/444618.html www.bkjia.com true http://www.bkjia.com/PHPjc/444618.html techarticle This article introduces you to a PHP Curl simulation post to submit XML data, because the recipient only accepts XML data so I wrote a, below to share to you friends, need friends ...