请问怎么用php 来post xml 对方接口只接受post过去的xml请问哈怎么用php post过去啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 懒得自己写了,给你个文章链接吧http://developer.51cto.com/art/200904/121739.htmhttp://developer.51cto.com/art/200904/121739.htm $fp = fsockopen($server, 80);fputs($fp, “POST $path HTTP/1.0\r\n”);fputs($fp, “Host: $server\r\n”);fputs($fp, “Content-Type: text/xml\r\n”);fputs($fp, “Content-Length: $contentLength\r\n”);fputs($fp, “Connection: close\r\n”);fputs($fp, “\r\n”); // all headers sentfputs($fp, $xml_data);$result = ”;while (!feof($fp)) {$result .= fgets($fp, 128);}return $result;网上找到的代码问题是那个length怎么求的的仅仅是xml字符串长度吗另外这个代码是对的吗我感觉有点问题应该是用流的方式 post的啊 类似上传文件啊 我是要post 一个文件 不是 简单的post数据 soap xmlrpc 都可以 uchome有xmlrpc自己看看不要这么懒一直要代码!给你提示就够好的了! XMLRPC 类http://blog.csdn.net/ihefe/archive/2010/12/09/6066241.aspxXMLRPC 使用http://blog.csdn.net/ihefe/archive/2010/12/09/6066263.aspx 可以用curl﹤?php$xmlData = file_get_contents("aa.xml");$curlPost = 'xmlData=' . urlencode($xmlData ) ;$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/bb.php'); //接口curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);$data = curl_exec();curl_close($ch);?﹥ 文本替换空格成逗号 大家来看看我的NGINX的日志 关于信息采集的程序 PHP生成图片 中文就乱码 phpinfo()里的path问题 soap调用无返回值值 下面功能使用jquery+php+ajax如何实现?请写出具体代码 一简单求和问题 PHPED的问题帮忙 thinkphp3.2.3用pdo连接数据库连接不上 PHP如何访问SOAP? 一段添加代码的问题
fputs($fp, “POST $path HTTP/1.0\r\n”);
fputs($fp, “Host: $server\r\n”);
fputs($fp, “Content-Type: text/xml\r\n”);
fputs($fp, “Content-Length: $contentLength\r\n”);
fputs($fp, “Connection: close\r\n”);
fputs($fp, “\r\n”); // all headers sent
fputs($fp, $xml_data);
$result = ”;
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
return $result;
网上找到的代码
问题是那个length怎么求的的仅仅是xml字符串长度吗另外这个代码是对的吗我感觉有点问题
应该是用流的方式 post的啊 类似上传文件啊
我是要post 一个文件 不是 简单的post数据
都可以
自己看看
不要这么懒一直要代码!
给你提示就够好的了!
http://blog.csdn.net/ihefe/archive/2010/12/09/6066241.aspxXMLRPC 使用http://blog.csdn.net/ihefe/archive/2010/12/09/6066263.aspx
$xmlData = file_get_contents("aa.xml");
$curlPost = 'xmlData=' . urlencode($xmlData ) ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/bb.php'); //接口
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec();
curl_close($ch);
?﹥