简体   繁体   English

将数据发布到同一站点上的另一个Joomla页面

[英]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. 我有一个Joomla控制器,可以对某些Google Checkout XML代码进行多次迭代。 What I want is during this iteration, POST data to another page - in the same site. 我想要的是在此迭代过程中,将数据POST到同一站点中的另一个页面。

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. iterator.php控制器会将数据发布到executor.php可能有2次甚至50次。

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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