使用 PHP 将数据字符串 PUT 到 XML 服务器
我需要输入一串数据,如下所示: '<;客户端>...<\客户端>'使用 PHP 到 XMl 服务器(示例 url:'http://example.appspot.com/examples')。 (上下文:将新客户端的详细信息添加到服务器)。
我尝试过使用 CURLOPT_PUT、一个文件和一个字符串(因为它需要 CURLOPT_INFILESIZE 和 CURLOPT_INFILE),但它不起作用!
还有其他 PHP 函数可以用来做这样的事情吗?我一直在四处寻找,但 PUT 请求信息很少。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为到目前为止我还没有使用过 cURL,所以我无法真正回答这个话题。如果您想使用 cURL,我建议您查看服务器日志并查看实际上不起作用的内容(所以:请求的输出真的是它应该的那样吗?)
如果您不介意切换到另一个技术/库我建议您使用 Zend HTTP Client 使用起来非常简单,包含起来也很简单,应该可以满足您的所有需求。特别是执行 PUT 请求就这么简单:
代码示例来自:Zend Framework 文档 # 原始数据请求
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:
Code sample is from: Zend Framework Docs # RAW-Data Requests
在 PHP 中使用 CURL 将字符串主体添加到 PUT 请求的另一种方法是:
我希望这会有所帮助!
Another way to add string body to the PUT request with CURL in PHP is:
I hope this helps!