php curl 转为 x-www-form-urlencoded 方式的坑【转】
PHP 方式 Form CURL 转为 www urlencoded
2023-09-27 14:25:31 时间
网上转变的方法基本都是写添加下面这句:
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
但加上去后却根本没效果。
要想以 x-www-form-urlencoded 方式发送,最关键其实是发送的数据格式。
方式from-data试发送的数据用的是array格式,而方式为 x-www-form-urlencoded 时需要用key=value&key=value的格式发送,发送的是string型的数据。
from-data数据的为:
$data = [
'name' => 'xiaoming',
'sex' => 1
];
x-www-form-urlencoded时的数据则要变为
http_build_query($data);
原文链接:https://blog.csdn.net/qq_35641923/article/details/81386708
相关文章
- 16.PHP_Ajax模拟服务器登录验证
- PHP数组缓存:三种方式JSON、序列化和var_export的比较
- Yar - Yet Another RPC framework for PHP
- 【PHP代码审计】 那些年我们一起挖掘SQL注入 - 5.全局防护Bypass之宽字节注入
- PHP+Redis 简单实现排行榜实战
- PHP+RabbitMQ消息队列的配置和使用方法【MQ】
- 在cmd窗口中运行php命令
- PHP全栈学习笔记7
- PHP 开发 APP 接口 学习笔记与总结 - APP 接口实例 [2] 首页 APP 接口开发方案 ① 读取数据库方式
- PHP 开发 APP 接口 学习笔记与总结 - JSON 方式封装通信接口
- PHP+jQuery 长文章分页类 ( 支持 url / ajax 分页方式 )
- PHP 操作数据库乱码 以及调试
- php 验证码
- PHP(基本语法)PHP中的Session-登录案例
- php中 如何找到session 的保存位置
- yum安装方式的php,切换NTS为ZTS版本
- PHP正则表达式教程
- 基于PHP规范的自动加载方式(composer配置)
- Centos下YUM安装PHP的两种方式
- PHP内核研究:HASH表和变量 【转】
- php phpmail发送邮件的效果
- LNMP之PHP服务的安装(FastCGI方式)
- LAMP之PHP服务的安装(libphp7.so方式)