So the gist is that I need to post XML data query to a gateway page to receive a XML response which O parse later, there can be anywhere from 3-60 queries to this web service, I unfortunately have to run a simple loop right now and do them one at a time. On the response side, I will only need 1 (or a max of 5) of the lines in the response, line 2 is the first line that I need containing image data. So I'd like the ability to select which lines I am reading in if at all possible.
I created a simple "Read in" function as I said out of a basic for loop, here's the code that I am currently using and would like to revise.
$part1 = 'XML Beginning'; $part2 = XML End'; $posts = array( 0 => 'SC-010052214', 1 => 'SC-000032972', 2 => 'SC-012535460', 3 => 'SC-011257289', 4 => 'SC-010134078' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://example.com/index.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER => 1); curl_setopt ($ch, CURLOPT_POST, 1); $count = count($posts); for($i=0;$i<$count;$i++) { curl_setopt ($ch, CURLOPT_POSTFIELDS, "payload=$part1{$posts[$i]}$part2"); $return[] = curl_exec ($ch); } curl_close ($ch); print_r($return);
Restrictions: I cannot use ?post=$data0&post=$data1&post=$data3 unfortunately, so I need a better solution. Other than that, I'd like to see what kinds of improvements can be made here.
Maybe http://php.net/manual/en/function.curl-multi-init.php helps you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With