ganqqwerty
ganqqwerty

Reputation: 1994

Owncloud webdav access from php

I'm trying to access my owncloud webdav interface and get the list of files in the root directory from PEAR WebDAV Client. I'm trying the following:

include("HTTP/WebDAV/Client.php");
$client = new HTTP_WebDAV_Client_Stream();

$user="admin";
$pass = "q1w2e3r4";

$dir = "webdavs://".$user.":".$pass."@127.0.0.1:10081/owncloud/remote.php/webdav/";

$stuff = $client->dir_opendir($dir, array());
var_dump($stuff);
var_dump($client->dirfiles);

The code print false, false, and when I've tried to debug it, I saw Connection refused error in Socket.php, when it tried to call the function

fsockopen("127.0.0.1", 10081, $err, $errstr);

It's even more strange since I can access this server and list the directories from cadaver though. Also I can access the test DAV server with my code by replacing my $dir variable:

$dir = "webdavs://".$user.":".$pass."@127.0.0.1:10081/owncloud/remote.php/webdav/";

Upvotes: 1

Views: 1763

Answers (1)

kguest
kguest

Reputation: 3844

It's an ugly hack, but if you add something similar to:

 var_dump($err->getMessage()); 

to /usr/share/php/HTTP/Request.php on line 739, you should be able to see the most relevant error message. (If that is where Request.php got installed to.)

Unfortunately, there doesn't appear to be a mechanism in place in the underlying HTTP_Request package for raising that specific error message back to the HTTP_WebDAV_Client_Stream code.

Upvotes: 1

Related Questions