file_get_contents 模拟POST数据发送
来源:互联网 发布:阿里妈妈采集软件 编辑:程序博客网 时间:2024/06/08 14:27
<?php
$postDate = array(
'title' => '天气好',
'content' => '今天是星期三',
); // 要发送的数据
$postDate = http_build_query($postDate); // 使用给出的关联(或下标)数组生成一个 url-encoded 请求字符串。
$opts = array(
'http'=>array(
'method'=>"POST",// post请求
'header'=>"Host:localhost\r\n" .
"Content-type:application/x-www-form-urlencoded\r\n" .
"Content-length:".strlen($postDate)."\r\n", // 首部 \r\n 回车换行
'content' => $postDate,// 内容
)
);
$context = stream_context_create($opts);//创建并返回一个资源流上下文,该资源流中包含了提前设定的所有参数的值。
file_get_contents("http://localhost/index2.php",false,$context);// 发送(关键是第三个参数)
?>
$postDate = array(
'title' => '天气好',
'content' => '今天是星期三',
); // 要发送的数据
$postDate = http_build_query($postDate); // 使用给出的关联(或下标)数组生成一个 url-encoded 请求字符串。
$opts = array(
'http'=>array(
'method'=>"POST",// post请求
'header'=>"Host:localhost\r\n" .
"Content-type:application/x-www-form-urlencoded\r\n" .
"Content-length:".strlen($postDate)."\r\n", // 首部 \r\n 回车换行
'content' => $postDate,// 内容
)
);
$context = stream_context_create($opts);//创建并返回一个资源流上下文,该资源流中包含了提前设定的所有参数的值。
file_get_contents("http://localhost/index2.php",false,$context);// 发送(关键是第三个参数)
?>
阅读全文
0 0
- file_get_contents 模拟POST数据发送
- PHP模拟发送POST请求之四、加强file_get_contents()发送POST请求
- socket 模拟POST发送数据
- file_get_contents模拟GET/POST请求
- php 模拟浏览器 发送 post 和 get 请求(兼容curl + file_get_contents)
- URL对象模拟POST发送数据!(原创)
- C# POST 模拟发送提交数据
- [PHP代码] php模拟post发送数据
- PHP 模拟post请求发送数据
- curl 模拟POST方法 发送数据
- php 模拟 post curl sock file_get_contents
- PHP利用Curl、socket、file_get_contents POST数据
- 利用Curl、socket、file_get_contents POST数据
- PHP - 利用Curl、socket、file_get_contents POST数据
- 利用Curl、socket、file_get_contents POST数据
- PHP利用Curl、socket、file_get_contents POST数据
- C#模拟Post和Get方式发送数据 保持COOKIE
- C#模拟Post和Get方式发送数据
- 3-2 构造函数的调用
- 多线程run()中经常写while(true)的作用
- (问题解决)Spring @Async无法注入Controller java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(
- C++运算符优先级
- viso画图时如何让右侧显示设置形状格式栏
- file_get_contents 模拟POST数据发送
- Swift 自动引用计数(ARC)
- STM32之RTC例程
- 微软操作系统 Windows Server 2012 R2 官方原版镜像 微软操作系统 Windows Server 2012 R2 官方原版镜像 Windows Server 2012 R2
- nRF52832 — 外部中断BSP(Board Support Package)
- ItemTouchHelper的使用
- ID3决策树(Java实现)
- CentOS自建Git服务端,Android Studio 添加自建远程库
- SpringMVC文件上传与下载