Curl_init () issue
I pass an XML document with Curl_init ()
--
$sql = "Select AA from BB";
$n = $DB->execsql ($sql);
while ($DB->fetch ()) {
$MD 5 = MD5 ($SRC. " &key=6c3d80558fec2784b20a95863dca9458 ");
$WEB = new Web_service ($HOST, N, $URL, "POST");
$WEB->addpara ("Para_xml", $SRC);
$WEB->addpara ("Md5data", $MD 5);
$WEB->addpara ("Customersid", "10058");
$ret = $WEB->run ();
$WEB->close (); }
The Run () function is approximate
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://". $this->ip. $this->url);
curl_setopt ($ch, Curlopt_returntransfer, true);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_postfields, $this->parameter);
$ret = curl_exec ($ch);
Curl_close ($ch);
Issue: The SQL statement detected 1000 data, but there may be 10 unsuccessful. If the unsuccessful 10 data transmission again, and the transmission is successful.
I found the problem is that in the loop repeatedly connected pages, sometimes the connection is not successful, that is, $ret = $WEB->run (); Returns a null value. So no transmission was successful.
How should such a problem be solved??
Do you want to add a sleep () after each data transfer to control the time of the repeat connection trigger?
------Solution--------------------
You can try it with sleep.
------Solution--------------------
You can see if the delivery is successful through Curl_getinfo.
You can also collect all the data, one-time pass
You can also pass it in multi-channel mode (CURL_MULTI)
------Solution--------------------
The status should be recorded, except for the completion of the re-submission
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