From 4ce7f1dc86def6f30cf7355ebf7f2812b3fc39e1 Mon Sep 17 00:00:00 2001 From: cp6 Date: Sun, 6 Jun 2021 11:39:43 +1000 Subject: [PATCH] Updated readme for video streaming API Updated readme for video streaming API --- README.md | 297 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 292 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9836a49..a4ac5a8 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ # BunnyCDN API Class -The most comprehensive, feature packed and easy to use PHP class for the BunnyCDN pull and storage zones [API](https://bunnycdn.docs.apiary.io/). -This class whilst having a main focus on storage zone interaction includes pull zone features. -Combining API with FTP, managing and using BunnyCDN storage zones just got easier. +The most comprehensive, feature packed and easy to use PHP class for the BunnyCDN pull, video streaming and storage +zones [API](https://bunnycdn.docs.apiary.io/). +This class whilst having a main focus on storage zone interaction includes pull zone features. Combining API with FTP, +managing and using BunnyCDN storage zones just got easier. -[![Generic badge](https://img.shields.io/badge/version-1.2-blue.svg)](https://shields.io/) +[![Generic badge](https://img.shields.io/badge/version-1.4-blue.svg)](https://shields.io/) + +**Note video streaming API is seemingly not finalized and is changing** ### Requires -For Pull zone, billing and statistics API interaction you will need your BunnyCDN API key, this is found in your dashboard in the My Account section. +For Pull zone, billing and statistics API interaction you will need your BunnyCDN API key, this is found in your +dashboard in the My Account section. If you want to interact with storage zones you will need your BunnyCDN API key set and the name of the storage zone. @@ -58,12 +62,15 @@ If you want to interact with storage zones you will need your BunnyCDN API key s * Calculate costs ## Usage + Usage is simple, install with: ``` composer require corbpie/bunny-cdn-api ``` + Use like: + ```php require __DIR__ . '/vendor/autoload.php'; @@ -87,23 +94,29 @@ const API_KEY = 'XXXX-XXXX-XXXX'; **option 2** With ```apiKey()``` (needs setting with each calling of class) + ```php $bunny->apiKey('XXXX-XXXX-XXXX');//Bunny api key ``` + --- To have max execution time of 300 seconds + ```php $bunny = new bunnyAPI(300); ``` + --- Storage zone name and access key for storage zone interaction (**not needed if just using pull zone functions**) Set ```$access_key = ''``` to obtain key automatically (storage name must be accurate) + ```php $bunny->zoneConnect($storagename, $access_key); ``` + `$storagename` name of storage zone `string` `$access_key` key/password to storage zone ```string``` **optional** @@ -111,6 +124,7 @@ $bunny->zoneConnect($storagename, $access_key); --- List storage zones + ```php $bunny->listStorageZones(); ``` @@ -120,22 +134,27 @@ returns `array` --- Add a storage zone + ```php $bunny->addStorageZone($newstoragezone); ``` + `$newstoragezone` name of storage zone to create `string` --- Delete a storage zone + ```php $bunny->deleteStorageZone($id); ``` + `$id` id of storage zone to delete `int` --- Get directory size + ```php $bunny->dirSize($dir); ``` @@ -145,6 +164,7 @@ $bunny->dirSize($dir); --- Return current directory + ```php $bunny->currentDir(); ``` @@ -154,14 +174,17 @@ returns `string` --- Change directory + ```php $bunny->changeDir($dir); ``` + `$dir` directory navigation (FTP rules) `string` --- Move to parent directory + ```php $bunny->moveUpOne(); ``` @@ -169,6 +192,7 @@ $bunny->moveUpOne(); --- Create folder in current directory + ```php $bunny->createFolder($newfolder); ``` @@ -178,6 +202,7 @@ $bunny->createFolder($newfolder); --- Delete folder + ```php $bunny->deleteFolder($name); ``` @@ -187,6 +212,7 @@ $bunny->deleteFolder($name); --- Delete a file + ```php $bunny->deleteFile($name); ``` @@ -196,6 +222,7 @@ $bunny->deleteFile($name); --- Delete all files in a folder + ```php $bunny->deleteAllFiles($dir); ``` @@ -207,6 +234,7 @@ $bunny->deleteAllFiles($dir); Rename a file BunnyCDN does not allow for ftp_rename so file copied to new name and then old file deleted. + ```php $bunny->renameFile($directory, $old_file_name, $new_file_name); ``` @@ -220,6 +248,7 @@ $bunny->renameFile($directory, $old_file_name, $new_file_name); --- Move a file + ```php $bunny->moveFile($file, $move_to); ``` @@ -231,6 +260,7 @@ $bunny->moveFile($file, $move_to); --- Download a file + ```php $bunny->downloadFile($save_as, $get_file, $mode); ``` @@ -244,6 +274,7 @@ $bunny->downloadFile($save_as, $get_file, $mode); --- Download all files in a directory + ```php $bunny->downloadAll($dir_dl_from, $dl_into, $mode); ``` @@ -257,6 +288,7 @@ $bunny->downloadAll($dir_dl_from, $dl_into, $mode); --- Upload a file + ```php $bunny->uploadFile($upload, $upload_as, $mode); ``` @@ -270,6 +302,7 @@ $bunny->uploadFile($upload, $upload_as, $mode); --- Upload all files from a local folder + ```php $bunny->uploadAllFiles($dir, $place, $mode); ``` @@ -283,14 +316,17 @@ $bunny->uploadAllFiles($dir, $place, $mode); --- Return storage zone files and folder data (Original) + ```php $bunny->listAllOG(); ``` + returns `array` --- Return storage zone directory files formatted + ```php $bunny->listFiles($location); ``` @@ -302,6 +338,7 @@ returns `array` --- Return storage zone directory folders formatted + ```php $bunny->listFolders($location); ``` @@ -313,6 +350,7 @@ returns `array` --- Return storage zone directory file and folders formatted + ```php $bunny->listAll($location); ``` @@ -324,14 +362,17 @@ returns `array` --- List all pull zones and data + ```php $bunny->listPullZones(); ``` + returns `array` --- List pull zones data for id + ```php $bunny->pullZoneData($id); ``` @@ -343,6 +384,7 @@ returns `array` --- Purge pull zone data + ```php $bunny->purgePullZone($id); ``` @@ -352,6 +394,7 @@ $bunny->purgePullZone($id); --- Delete pull zone data + ```php $bunny->deletePullZone($id); ``` @@ -361,12 +404,15 @@ $bunny->deletePullZone($id); --- Lists pullzone hostnames and amount + ```php $bunny->pullZoneHostnames($pullzone_id); ``` + --- Add hostname to pull zone + ```php $bunny->addHostnamePullZone($id, $hostname); ``` @@ -378,6 +424,7 @@ $bunny->addHostnamePullZone($id, $hostname); --- Remove a hostname from pull zone + ```php $bunny->removeHostnamePullZone($id, $hostname); ``` @@ -389,6 +436,7 @@ $bunny->removeHostnamePullZone($id, $hostname); --- Change force SSL status for pull zone + ```php $bunny->forceSSLPullZone($id, $hostname, $force_ssl); ``` @@ -402,6 +450,7 @@ $bunny->forceSSLPullZone($id, $hostname, $force_ssl); --- Add ip to block for pullzone + ```php $bunny->addBlockedIpPullZone($pullzone_id, $ip, $db_log = false); ``` @@ -409,6 +458,7 @@ $bunny->addBlockedIpPullZone($pullzone_id, $ip, $db_log = false); --- Un block an ip for pullzone + ```php $bunny->unBlockedIpPullZone($pullzone_id, $ip, $db_log = false); ``` @@ -416,6 +466,7 @@ $bunny->unBlockedIpPullZone($pullzone_id, $ip, $db_log = false); --- List all blocked ip's for pullzone + ```php $bunny->listBlockedIpPullZone($pullzone_id); ``` @@ -423,6 +474,7 @@ $bunny->listBlockedIpPullZone($pullzone_id); --- Purge cache for a URL + ```php $bunny->purgeCache($url); ``` @@ -432,6 +484,7 @@ $bunny->purgeCache($url); --- Pull zone logs as formatted array + ```php $bunny->pullZoneLogs($id, $date); ``` @@ -443,84 +496,318 @@ $bunny->pullZoneLogs($id, $date); --- Get usage statistics + ```php $bunny->getStatistics(); ``` + returns `array` --- Get billing data + ```php $bunny->getBilling(); ``` + returns `array` --- Get account balance + ```php $bunny->balance(); ``` + returns `float` --- Get monthly charge + ```php $bunny->monthCharges(); ``` + returns `float` --- Get monthly charge breakdown for region + ```php $bunny->monthChargeBreakdown(); ``` + returns `array` --- Lists total billing amount and first date time + ```php $bunny->totalBillingAmount(); ``` + returns `array` --- Apply a coupon code + ```php $bunny->applyCoupon($code); ``` + --- Set Json header + ```php $bunny->jsonHeader(); ``` + --- Convert/format bytes to other data types + ```php $bunny->convertBytes($bytes, $convert_to = 'GB', $format = true, $decimals = 2); ``` + --- Convert bool to int value + ```php $bunny->boolToInt($bool); ``` + returns `int` --- Close connection (Optional) + ```php $bunny->closeConnection(); ``` +--- + +## Video streaming + +Set video stream library id + +```php +$bunny->setStreamLibraryId($library_id); +``` + +`$library_id` stream library id `int` + +--- + +Set video collection guid + +```php +$bunny->setStreamCollectionGuid($collection_guid); +``` + +`$collection_guid` video collection guid `string` + +--- + +Set video guid + +```php +$bunny->setStreamVideoGuid($video_guid); +``` + +`$video_guid` video guid `string` + +--- + +Get video collections for library + +```php +$bunny->getStreamCollections($library_id, $page, $items_pp,$order_by); +``` + +`$library_id` library id `int` + +*0 = use set library id from setStreamLibraryId()* + +`$page` page number `int` + +`$items_pp` items to show `int` + +`$order_by` order by `string` + +--- + +Get streams for a collection + +```php +$bunny->getStreamForCollection($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +*0 = use set library id from setStreamLibraryId()* + +`$collection_guid` video collection guid `string` + +*leave empty to use set collection guid from setStreamCollectionGuid()* + +--- + +Update stream collection + +```php +$bunny->updateCollection($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +Delete stream collection + +```php +$bunny->deleteCollection($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +Create stream collection + +```php +$bunny->createCollection($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +List videos for library + +```php +$bunny->listVideos($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +Get video information + +```php +$bunny->getVideo($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +Delete video + +```php +$bunny->deleteVideo($library_id, $collection_guid); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +--- + +Create video + +```php +$bunny->createVideo($library_id, $video_title, $collection_guid); +``` + +`$library_id` library id `int` + +`$video_title` video title `string` + +`$collection_guid` video collection guid `string` + +--- + +Upload video + +Need to use createVideo() first to get video guid + +```php +$bunny->uploadVideo($library_id, $collection_guid, $video_to_upload); +``` + +`$library_id` library id `int` + +`$collection_guid` video collection guid `string` + +`$video_to_upload` video file `string` + +--- + +Set thumbnail for video + +```php +$bunny->setThumbnail($library_id, $video_guid, $thumbnail_url); +``` + +`$library_id` library id `int` + +`$video_guid` video guid `string` + +`$thumbnail_url` image url `string` + +--- + +Add captions + +```php +$bunny->addCaptions($library_id, $video_guid, $collection_guid, $label, $captions_file); +``` + +`$library_id` library id `int` + +`$video_guid` video guid `string` + +`$srclang` caption srclang `string` + +`$label` label for captions `string` + +`$captions_file` caption file URL `string` + +--- + +Delete captions + +```php +$bunny->deleteCaptions($library_id, $video_guid, $srclang); +``` + +`$library_id` library id `int` + +`$video_guid` video guid `string` + +`$srclang` captions srclang `string` ---