当前位置:网站首页>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);边栏推荐
- Oil monkey script link
- Layout management ==pyqt5
- Menu bar + status bar + toolbar ==pyqt5
- JS作用域以及预解析
- The most efficient note taking method in the world (change your old version of note taking method)
- Brief description of model deployment
- JS运算符
- 小程序image 无法显示base64 图片 解决办法 有效
- 第4章线性方程组
- Wiznet embedded Ethernet technology training open class (free!!!)
猜你喜欢
随机推荐
基于W5500实现的考勤系统
brpc源码解析(五)—— 基础类resource pool详解
软件缺陷的管理
OneNET平台控制W5500开发板LED灯
'C:\xampp\php\ext\php_zip.dll' - %1 不是有效的 Win32 应用程序 解决
JS运算符
信号与槽机制==PYQT5
Return and finally? Everyone, please look over here,
【高并发】我用10张图总结出了这份并发编程最佳学习路线!!(建议收藏)
cookie and session
[leetcode brush questions]
PHP curl post x-www-form-urlencoded
菜单栏+状态栏+工具栏==PYQT5
奉劝那些刚参加工作的学弟学妹们:要想进大厂,这些并发编程知识是你必须要掌握的!完整学习路线!!(建议收藏)
toString()与new String()用法区别
阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程
GPT plus money (OpenAI CLIP,DALL-E)
brpc源码解析(一)—— rpc服务添加以及服务器启动主要过程
Maskgae: masked graph modeling meets graph autoencoders
软件测试阶段的风险








![[electronic device notes 5] diode parameters and selection](/img/4d/05c60641dbdbfbfa6c3cc19a24fa03.png)
