Hi All,
With reference to this post from me a few days ago, I am trying to write a simple php page to take a URL, username and password and to then load a list of all files that could be restored with tick boxes and a “select all” button (maybe also some date to / from options as well later).
I’ve got the code working to pull the “capabilities” from the server and that seem to be working well but I’m not currently managing to get the dav trash-bin stuff working. Code is below, could someone take a quick look and point me to where I am going wrong?
$apiUrl = ‘https://’ . $fqdn . ‘remote.php/dav/trash-bin/’ . $username;
// also tried
// $apiUrl = ‘https://$username:$password@$fqdn/remote.php/dav/trash-bin/$username’;
$apiCurl = curl_init();
curl_setopt($apiCurl, CURLOPT_USERPWD, $userUsername . “:” . $userPassword);
curl_setopt($apiCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($apiCurl, CURLOPT_URL, $apiUrl);
curl_setopt($apiCurl, CURLOPT_HTTPHEADER, array(’
Depth: 1;
Content-Type: application/xml;
charset=UTF-8’));
curl_setopt($apiCurl, CURLOPT_CUSTOMREQUEST, ‘PROPFIND’);
curl_setopt($apiCurl, CURLOPT_POSTFIELDS,’
<d:propfind xmlns:d=“DAV:” xmlns:oc=“http://owncloud.org/ns”>
<d:prop>
<oc:trashbin-original-filename />
<oc:trashbin-original-location />
<oc:trashbin-delete-datetime />
<d:getcontentlength />
<d:resourcetype />
</d:prop>
</d:propfind>
');$curlResult = curl_exec($apiCurl);
$deletedFiles = json_decode($curlResult, true);var_dump ($deletedFiles);
Any help would be appreciated, fairly sure I’m just not getting something quite right in the curl options / headers / post settings.