doujia5863 2011-04-28 14:31
浏览 42

使用PHP将数据字符串输出到XML服务器

I need to put a string of data like so: '< client>...<\client>' onto an XMl server (example url:'http://example.appspot.com/examples') using PHP. (Context: Adding a new client's details to the server).

I have tried using CURLOPT_PUT, with a file and with just a string (since it requires CURLOPT_INFILESIZE and CURLOPT_INFILE) but it does not work!

Are there any other PHP functions that could be used to do such a thing? I have been looking around but PUT requests information is sparse.

Thanks.

  • 写回答

3条回答 默认 最新

  • dongzhou8764 2011-04-28 14:48
    关注

    since I haven't worked with cURL so far I can't really answer to that topic. If you'd like to use cURL I'd suggest looking at the server log and see what actually didn't work (so: Was the output of the request really what it's supposed to be?)

    If you don't mind switching over to another technology/library I'd suggest you to use the Zend HTTP Client which is really straight forward to use, simple to include and should satisfy all your needs. Especially as performing a PUT Request is as simple as that:

    <?php 
       // of course, perform require('Zend/...') and 
       // $client = new Zend_HTTP_Client() stuff before
       // ...
       [...]
       $xml = '<yourxmlstuffhere>.....</...>';
       $client->setRawData($xml)->setEncType('text/xml')->request('PUT');
    ?>
    

    Code sample is from: Zend Framework Docs # RAW-Data Requests

    评论

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题