如何使用 PHP 和 cURL 转发 $_POST? [英] How can I forward $_POST with PHP and cURL?

查看:30
本文介绍了如何使用 PHP 和 cURL 转发 $_POST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 PHP 脚本中收到一个 POST 请求,并且也想使用 POST 将此 POST 调用转发到另一个脚本.我该怎么做?

I receive a POST request at my PHP script and would like to forward this POST call to another script using POST too. How can I do this?

如果此操作需要,我可以使用 cURL.

I can use cURL if it's required for this action.

推荐答案

也许:

curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);

来自curl_setopt:

这既可以作为 urlencoded 字符串(如 'para1=val1&para2=val2&...')传递,也可以作为以字段名称作为键和字段数据作为值的数组传递.
This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value.

这篇关于如何使用 PHP 和 cURL 转发 $_POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆