PHP、CURL、WebDAV 和 SEARCH 方法
如何在 PHP 中重新创建以下curl 语句?
curl http://www.example.com/path/to/folder/ -X SEARCH -d @dasl.xml
这是我到目前为止所拥有的,“dasl.xml”文件是让我困惑的。
$ch = curl_init("http://www.example.com/path/to/folder/");
$fp = fopen("webdav.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "SEARCH");
curl_exec($ch);
curl_close($ch);
fclose($fp);
dasl.xml 文件包含用于查询 WebDAV 的 XML。我可以使用一个选项来传递该文件吗?或者有没有办法将文件的内容作为字符串或其他内容传递?
我目前收到的错误声明是
DaslStatement:267 - SAX 解析器错误文件过早结束。
感谢您的帮助。
更新:
这是一个 dasl.xml 文件示例:
<d:searchrequest xmlns:d="DAV:">
<d:basicsearch>
<d:select>
<d:prop><d:getcontentlength/></d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/container1/</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:gt>
<d:prop><d:getcontentlength/></d:prop>
<d:literal>10000</d:literal>
</d:gt>
</d:where>
<d:orderby>
<d:order>
<d:prop><d:getcontentlength/></d:prop>
<d:ascending/>
</d:order>
</d:orderby>
</d:basicsearch>
</d:searchrequest>
有关 DASL 的更多信息,请参见:http://greenbytes.de/tech/webdav/rfc5323.html 和 [http://www.webdav.org/dasl/][2]
How would I recreate the following curl statement in PHP?
curl http://www.example.com/path/to/folder/ -X SEARCH -d @dasl.xml
Here is what I have so far, and the "dasl.xml" file is what is tripping me up.
$ch = curl_init("http://www.example.com/path/to/folder/");
$fp = fopen("webdav.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "SEARCH");
curl_exec($ch);
curl_close($ch);
fclose($fp);
The dasl.xml file contains the XML to query WebDAV. Is there an option that I can use to pass that file along? Or is there a way to pass along the contents of the file as a string or something else?
The error statement that I'm currently getting is
DaslStatement:267 - SAX parser error Premature end of file.
Thanks for the help.
Update:
Here is an example dasl.xml file:
<d:searchrequest xmlns:d="DAV:">
<d:basicsearch>
<d:select>
<d:prop><d:getcontentlength/></d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/container1/</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:gt>
<d:prop><d:getcontentlength/></d:prop>
<d:literal>10000</d:literal>
</d:gt>
</d:where>
<d:orderby>
<d:order>
<d:prop><d:getcontentlength/></d:prop>
<d:ascending/>
</d:order>
</d:orderby>
</d:basicsearch>
</d:searchrequest>
More info on DASL here: http://greenbytes.de/tech/webdav/rfc5323.html and [http://www.webdav.org/dasl/][2]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
file_get_contents
与自定义上下文结合使用。所以你不需要 cURL 来实现这一点。与此类似的东西:You can use
file_get_contents
with a custom context. So you would not need cURL for that. Something similar to this: