对方接口只接受post过去的xml请问哈
怎么用php 
post过去啊

解决方案 »

  1.   

    懒得自己写了,给你个文章链接吧http://developer.51cto.com/art/200904/121739.htmhttp://developer.51cto.com/art/200904/121739.htm
      

  2.   

    $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 sent
    fputs($fp, $xml_data);
    $result = ”;
    while (!feof($fp)) {
    $result .= fgets($fp, 128);
    }
    return $result;
    网上找到的代码
    问题是那个length怎么求的的仅仅是xml字符串长度吗另外这个代码是对的吗我感觉有点问题
    应该是用流的方式 post的啊 类似上传文件啊
      

  3.   


    我是要post 一个文件 不是 简单的post数据
      

  4.   

    soap xmlrpc  
    都可以
      

  5.   

    uchome有xmlrpc
    自己看看
    不要这么懒一直要代码!
    给你提示就够好的了!
      

  6.   

    XMLRPC 类
    http://blog.csdn.net/ihefe/archive/2010/12/09/6066241.aspxXMLRPC 使用http://blog.csdn.net/ihefe/archive/2010/12/09/6066263.aspx
      

  7.   

    可以用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);
    ?﹥