PHP Curl Analog Post submit XML Data _php Tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.