php使用curl提交xml数据
$xml_data ='<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[OK]]></return_msg>
</xml>
'; $URL = "http://localhost/aa.php";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //禁用后cURL将终止从服务端进行验证
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); //设置header
curl_setopt($ch, CURLOPT_POST, 1); //post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //将curl_exec()获取的信息以文件流的形式返回,而不是直接输出
$data = curl_exec($ch);
if($data){
curl_close($ch);
echo($data);
}
else{
$error = curl_errno($ch);
curl_close($ch);
echo("curl出错,错误码:$error");
}
<?php
echo "<pre>";
var_dump($_POST);
$data = file_get_contents('php://input'); //都要解下码
var_dump(($data));
echo "<br>";
var_dump(($GLOBALS['HTTP_RAW_POST_DATA']));
?>
php使用curl提交xml数据的更多相关文章
- php通过curl发送XML数据,并获取XML数据
php编程中经常会用到用xml格式传送数据,如调用微信等第三方接口经常用到,这里演示下php以curl形式发送xml,并通过服务器接收 一.发送xml数据 -- postXml.php <?ph ...
- cURL模拟POST方法提交XML数据并解析
php编程中会用到xml格式传送数据,这里演示下php以post形式发送xml,服务器接收,并解析xml的过程! post_xml.php源码: <?php header("Conte ...
- 使用 PHP cURL 提交 JSON 数据
http://www.oschina.net/code/snippet_54100_7351 http://www.lornajane.net/posts/2011/posting-json-data ...
- AJAX+cURL+SimpleXMLElement处理数据
curl_xml.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- PHP接收和发送XML数据(json也通用)
一.接收xml数据, 使用php://input,代码如下: <?php $xmldata=file_get_contents("php://input"); $data=s ...
- curl之post提交xml
直接上代码: /** * 以post方式提交xml到对应的接口url * * @param string $xml 需要post的xml数据 * @param string $url url * @p ...
- curl提交数据时中文乱码
1.使用curl提交数据时中文乱码解决: <?php $testJSON=array('name'=>'中文字符串','value'=>'test'); foreach ( $tes ...
- [C#]Winform后台提交数据且获取远程接口返回的XML数据,转换成DataSet
#region 接口返回的Xml转换成DataSet /// <summary> /// 返回的Xml转换成DataSet /// </summary> /// <par ...
- servlet对form提交的数据进行XML转换后发送
今天遇到一个项目,要求对form表单提交的数据进行以xml格式发送出去: 直接写XMLUtil工具类如下: package com.yfit.controller; import javax.serv ...
随机推荐
- CSS居中方法
css居中方法非常多,根据工作的实际情况采用恰当方法,可取到事半功倍的效果. 就常见的一些居中方法整理如下: 代码如下: <div class="con"> <d ...
- CodeFroces--Good Bye 2016-B--New Year and North Pole(水题-模拟)
B. New Year and North Pole time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- 【第四篇】androidEventbus源代码阅读和分析
1,分析androidEventbus的注册源代码: 我们在使用androidEventbus的第一步是注册eventbus,如下代码: EventBus.getDefault().register( ...
- python2.7学习记录之三
1.连接数据库 MySQLdb的是一个接口连接到MySQL数据库服务器从Python.它实现了Python数据库API V2.0,并建上的MySQL C API的顶端. 下载地址:https://so ...
- zencart低版本由php5.2.17升级PHP5.3环境下错误及解决方案
方法:有错误或者空白先打开错误提示,ftp看cache错误日志 或者 面板查看错误日志,再对比数据库是否正确,可拿脚本看是否能连接 \cp -r backipmysql/nlbarb_007li/ ...
- Chapter 2 Open Book——12
I called him in when dinner was ready, and he sniffed appreciatively as he walked into the room. 当晚饭 ...
- POJ 1258 Agri-Net(Prim)
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<cmath> #include<algori ...
- hdu_5690_All X(找循环节)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5690 题意: Problem Description F(x, m)F(x,m) 代表一个全是由数字x ...
- hdu_1011_Starship Troopers(树形DP)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1011 题意:有N个房间,房间的连通性为树形的,就是说你要占领子结点,必须要先占领 父结点,每个房间有第 ...
- passwd总结
1.当前用户是root root用户修改密码 ,直接 passwd[不要输入当前用户密码] 如果修改其他用户密码,需要 passwd 用户名 如: passwd sc 短短的密码,如123也能通过,因 ...