PHP技术现实HTTP提交POST事件
来源:互联网 发布:知乎 阿里 投资 编辑:程序博客网 时间:2024/05/22 09:39
本帖最后由 wcpsoft 于 2011-11-28 07:37 编辑
最近做项目,使用了HTTP请求POST提交XML事件,并返回数据的程序。现在我就和大家分享一下。
set_time_limit(0);
include 'conf.php';
$filename = "234.XML";
$file = fopen($filename,"r");
$filesize = filesize($filename);
$body = fread($file,$filesize); //将XML读出保存到$body变量中
$http_url="http://127.0.0.1:8888/AdapterInboundPoint"; //定义请求地址
$post_header[]="POST $http_url HTTP/1.1"; //根据实际需要编写请求header
$post_header[]="hai.method:test";
$post_header[]="hai.targetLogicApp:test.PL.0";
$post_header[]="hai.targetLogicService:test";
$post_header[] ="hai.sourceLogicApp:test.TEST.HXZ";
$post_header[] ="Content-Type:text/html; charset=utf-8";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $http_url); //连接地址
curl_setopt($ch, CURLOPT_HTTPHEADER, $post_header); //发送头
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); //传送XML
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_NOBODY,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch); //返回结果
$info = curl_getinfo($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //返回状态码
curl_close($ch);
echo $info['url'] . ''. $info['total_time'] . ''.''.$code.'<br/>';
echo '<br/><font color="#FF0000">'.$data.'</font><br/>';
最近做项目,使用了HTTP请求POST提交XML事件,并返回数据的程序。现在我就和大家分享一下。
set_time_limit(0);
include 'conf.php';
$filename = "234.XML";
$file = fopen($filename,"r");
$filesize = filesize($filename);
$body = fread($file,$filesize); //将XML读出保存到$body变量中
$http_url="http://127.0.0.1:8888/AdapterInboundPoint"; //定义请求地址
$post_header[]="POST $http_url HTTP/1.1"; //根据实际需要编写请求header
$post_header[]="hai.method:test";
$post_header[]="hai.targetLogicApp:test.PL.0";
$post_header[]="hai.targetLogicService:test";
$post_header[] ="hai.sourceLogicApp:test.TEST.HXZ";
$post_header[] ="Content-Type:text/html; charset=utf-8";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $http_url); //连接地址
curl_setopt($ch, CURLOPT_HTTPHEADER, $post_header); //发送头
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); //传送XML
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_NOBODY,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch); //返回结果
$info = curl_getinfo($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //返回状态码
curl_close($ch);
echo $info['url'] . ''. $info['total_time'] . ''.''.$code.'<br/>';
echo '<br/><font color="#FF0000">'.$data.'</font><br/>';
- PHP技术现实HTTP提交POST事件
- php http模拟POST提交上传图片
- android 现实 HTTP GET/POST
- PHP的三种HTTP请求,php模拟post 提交
- http post提交数据
- http post提交数据
- $http.post提交示例
- http post提交数组
- PHP curl_init Post 提交
- php post 提交
- PHP CURL POST提交
- php 模拟POST提交
- php post get提交
- php http post 方式有curl 、 file_get_content 、 fsocket ,来post提交数据
- 使用file_get_contents提交http post
- 使用file_get_contents提交http post
- HTTP 模拟POST方式提交
- Http Post、Get提交工具
- 如何和外国人流利对话:出国英语900句 (1-300)
- 精品代码收藏,AU3规划桌面图标坐标。
- 过滤器2
- (转)五年教学实践与思考的结晶——推荐邹欣老师的《现代软件工程讲义》目录
- 如何学好算法与程序设计
- PHP技术现实HTTP提交POST事件
- zoj 2109 || hdoj1009 FatMouse' Trade(贪心)
- 108. Custom is a second nature. 习惯是后天养成的
- html在线编译器
- 频繁模式挖掘总结
- Struts2 的Action中取得请求参数值的几种方法
- WINCE6.0+S3C6410睡眠和唤醒的实现
- 继承关系树的每个具体类对应一张表
- 第十三周四天