An object oriented API to consume from PHP. The idea of this API is to manage all the files download, upload and sharing.
It is still on development, for now we only have this:
- File Sharing
- Get all shared files and folders
- Get a shared file
- Create a new share
- Delete a share
The API was tested with Owncloud 6.*
- Manage by webdav files, listings, download, upload, etc.
- Create a object entity to manage the File.
- Internationalization of message errors.
- Test, test, test, test
Through composer, simply run :
$ php composer.phar require gpilla/php-owncloud-api:dev-master
Or edit your composer.json:
// composer.json
{
"require": {
"gpilla/php-owncloud-api": "dev-master"
}
}
$ git clone https://github.com/gpilla/php-owncloud-api.git
$ cd php-owncloud-api
$ php composer.phar install --dev
In the contrib folder there is a hook for checking phpunit and phpcs before commiting.
Is based on league/flysystem and the API is here: http://flysystem.thephpleague.com/api/
(It will be changed)
Examples:
// As everytime instantiate the API
$api = new Owncloud\Api('http://host.foobar.com/', 'user', 'password');
$api->fileManagement()->read('path/to/the/test/file.txt');
See: http://doc.owncloud.org/server/6.0/admin_manual/sharing_api/get_all_shares.html
Usage:
$api = new Api('http://somewhere.com', 'user', 'password');
$shares = $api->fileSharing()->getAllShares();
$api = new Api('http://somewhere.com', 'user', 'password');
// You should send the share ID as parameter
$share = $api->fileSharing()->getShare(1);
$api = new Api('http://somewhere.com', 'user', 'password');
$share = $api->fileSharing()->createNewShare(
'path/to/file/or/folder'
, ['shareType' => Owncloud\Api\FileSharing::SHARE_TYPE_PUBLIC_LINK]
);
$api = new Api('http://somewhere.com', 'user', 'password');
// You should send the share ID as parameter
$share = $api->fileSharing()->deleteShare(1);