php curl如何发送 l,如何使用cURL发送原始POST数据? (PHP)

您的发送方/接收方周期的响应部分出现错误.

虽然这很可能是发送方的问题(它没有发送正确的请求),但也可能是由接收PHP脚本中的配置错误引起的.也就是说,即使请求是正确的,接收器也可能没有HTTP_RAW_POST_DATA可用.

Always populate the $HTTP_RAW_POST_DATA containing the raw POST data.

Otherwise, the variable is populated only with unrecognized MIME type

of the data. However, the preferred method for accessing the raw POST

data is php://input. $HTTP_RAW_POST_DATA is not available with

enctype=”multipart/form-data”.

因此,首先要检查的是是否确实填充了$HTTP_RAW_POST_DATA,从上面的页面要求:

> .ini变量always_populate_raw_post_data为True,

>或POST与POST处理程序无法识别的Content-Type一起发送(也许可以使用“text / raw”)

此时,正确的发送数据的方式将是

curl_setopt($handle, CURLOPT_POSTFIELDS, urlencode('Raw POST data'));

但是,请注意,接收这些数据的推荐方法根本不是依赖于$HTTP_RAW_POST_DATA,而是要读取虚拟文件php:// input的内容.

php://input is a read-only stream that allows you to read raw data

from the request body. In the case of POST requests, it is preferable

to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Moreover, for those cases where $HTTP_RAW_POST_DATA is not populated by default, it is a potentially less memory intensive alternative to activating always_populate_raw_post_data.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值