PHP Multi XML POST with loop using CURL -


i have multiple xml_payload's post (different xml posts each while loop). when run loop post data of first $i loop. how can post new data each $i loop?

$i = 0; while ($i < $num) {  ...data  define("xml_payload", "<?xml stuff , tags?>"); define("xml_post_url", "http://theurl");  $ch = curl_init(); curl_setopt($ch, curlopt_url, xml_post_url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 30); curl_setopt($ch, curlopt_postfields, xml_payload);  $result = curl_exec($ch); curl_close($ch);  $i++; } 

define defines constant. means cannot change once set. should use variables that:

define("xml_post_url", "http://theurl"); $i = 0; while ($i < $num) {  ...data  $xml_payload = "<?xml stuff , tags?>";  $ch = curl_init(); curl_setopt($ch, curlopt_url, xml_post_url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 30); curl_setopt($ch, curlopt_postfields, xml_payload);  $result = curl_exec($ch); curl_close($ch);  $i++; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -