简体   繁体   中英

POST data to another Joomla page on the same site

I have a Joomla controller that iterates a number of times over some Google Checkout XML code. What I want is during this iteration, POST data to another page - in the same site.

so

com_mycomponent/controllers/checkout_iterator.php //breaks up the xml into small parts and posts then to the executor, one at a time
com_mycomponent/controllers/checkout_executor.php //does the real work for each XML element it is passed

The iterator.php controller will POST data to executor.php maybe 2 or even 50 times.

How can I do this?

要将数据发布到php中的页面,可以使用cURL扩展名

A quick and dirty way may be like this..

$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'com_mycomponent/controllers/checkout_executor.php');
curl_setopt($c, CURLOPT_HEADER, false);
curl_setopt($c, CURLOPT_POST, true);

// send data
curl_setopt($c, CURLOPT_POSTFIELDS, 'a=1&b=2..');
curl_exec($c);
// other data.. we can use same handle
curl_setopt($c, CURLOPT_POSTFIELDS, 'a=1&b=2..');
curl_exec($c);

// don't forget to close
curl_close($c);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM