当前位置:网站首页>PHP curl post x-www-form-urlencoded
PHP curl post x-www-form-urlencoded
2022-07-25 11:56:00 【hexiaoniao】
Interface in postman The test inside was successful . however PHP curl post This The interface failed

I figured it out later . Reason for request header . The request header of this interface is x-www-form-urlencoded. therefore curl post It should also be changed to this
if($url == "" || $timeout <= 0){
return false;
}
$post_data = http_build_query($post_data);// a key
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);// Don't grab header information . Just return data
curl_setopt($curl, CURLOPT_TIMEOUT, (int)$timeout);// timeout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//1 Means not to return bool value
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));// a key
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
$data = curl_exec($curl);
if (curl_errno($curl)) {
return curl_error($curl);
}
curl_close($curl);边栏推荐
- 浅谈低代码技术在物流管理中的应用与创新
- Functions in JS
- Javescript loop
- 矩阵的特征值和特征向量
- The bank's wealth management subsidiary accumulates power to distribute a shares; The rectification of cash management financial products was accelerated
- 菜单栏+状态栏+工具栏==PYQT5
- A beautiful gift for girls from programmers, H5 cube, beautiful, exquisite, HD
- [MySQL learning 09]
- 已解决The JSP specification requires that an attribute name is preceded by whitespace
- Layout management ==pyqt5
猜你喜欢

pycharm连接远程服务器ssh -u 报错:No such file or directory

JVM performance tuning methods

Eigenvalues and eigenvectors of matrices

剑指 Offer 22. 链表中倒数第k个节点

Information management system for typical works of urban sculpture (picture sharing system SSM)

OneNET平台控制W5500开发板LED灯

30 sets of Chinese style ppt/ creative ppt templates

Qin long, a technical expert of Alibaba cloud: a prerequisite for reliability assurance - how to carry out chaos engineering on the cloud

JS operator
![[MySQL learning 08]](/img/9e/6e5f0c4c956ca8dc31d82560262013.png)
[MySQL learning 08]
随机推荐
Common linear modulation methods based on MATLAB
什么是全局事件总线?
软件测试阶段的风险
小程序image 无法显示base64 图片 解决办法 有效
Small program of vegetable distribution in community
W5500多节点连接
JS流程控制
Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
Arrays in JS
创新突破!亚信科技助力中国移动某省完成核心账务数据库自主可控改造
cookie and session
Teach you how to configure S2E as the working mode of TCP server through MCU
[leetcode brush questions]
程序员送给女孩子的精美礼物,H5立方体,唯美,精致,高清
油猴脚本链接
pycharm连接远程服务器ssh -u 报错:No such file or directory
brpc源码解析(一)—— rpc服务添加以及服务器启动主要过程
Dynamic planning problem 03_ Maximum sub segment sum
Hardware peripherals =maixpy3
教你如何通过MCU配置S2E为TCP Client的工作模式