Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP、CURL、WebDAV和搜索方法_Php_Search_Curl_Webdav - Fatal编程技术网

PHP、CURL、WebDAV和搜索方法

PHP、CURL、WebDAV和搜索方法,php,search,curl,webdav,Php,Search,Curl,Webdav,如何在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, $

如何在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);
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>

/集装箱1/
无穷
10000

更多关于DASL的信息请点击此处:和[http://www.webdav.org/dasl/][2]

您可以在自定义上下文中使用
file\u get\u contents
。所以你不需要卷曲。类似于此:

$url = 'http://www.example.com/path/to/folder/';
$body = file_get_contents('dasl.xml');
$context = stream_context_create(array(
    'http' => array(
      'method' => 'SEARCH',
      'header' => 'Content-type: application/x-www-form-urlencoded',
      'content' => $body,
    )
));

$response = file_get_contents($url, false, $context);

您需要解释一下
dasl.xml
中的内容。DASL文件是用于构建搜索的XML。下面是一个示例DASL文件。此文件与我的数据不匹配,因此我不打算将其发送到WebDAV服务器/集装箱1/无限10000