PHP code example of corbpie / bunny-cdn-api
1. Go to this page and download the library: Download corbpie/bunny-cdn-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
corbpie / bunny-cdn-api example snippets
use Corbpie\BunnyCdn\BunnyAPIPull;
$bunny = new BunnyAPIPull();//Initiate the class
echo $bunny->listPullZones();
const API_KEY = 'XXXX-XXXX-XXXX';
$bunny->apiKey('XXXX-XXXX-XXXX');//Bunny api key
use Corbpie\BunnyCdn\BunnyAPIStorage;
$bunny = new BunnyAPIStorage();
$bunny->zoneConnect($storagename, $access_key);
$bunny->listStorageZones();
$bunny->addStorageZone($newstoragezone);
$bunny->deleteStorageZone($id);
$dir = "media/images/dogs";
$bunny->dirSize($dir);
$bunny->currentDir();
$dir = "media/images/dogs";
$bunny->changeDir($dir);
$bunny->folderExists($path);
$file = "media/images/dogs/collie.jpg";
$bunny->fileExists($file);
$bunny->moveUpOne();
$new_folder = "dogs"
$bunny->createFolder($new_folder);
$bunny->deleteFolder($folder_name);
$bunny->deleteFile($name);
$bunny->deleteAllFiles($dir);
$directory = "media/images/dogs";
$old_file_name = "collie.jpg";
$new_file_name = "poodle.jpg";
$bunny->renameFile($directory, $old_file_name, $new_file_name);
$bunny->moveFile($file, $move_to);
$bunny->downloadFile($save_as, $get_file, $mode);
$bunny->downloadAll($dir_dl_from, $dl_into, $mode);
$bunny->uploadFile($upload, $upload_as, $mode);
$bunny->uploadAllFiles($dir, $place, $mode);
$bunny->listAllOG();
$bunny->listFiles($location);
$bunny->listFolders($location);
$bunny->listAll($location);
$bunny->listPullZones();
$bunny->pullZoneData($id);
$bunny->purgePullZone($id);
$bunny->deletePullZone($id);
$bunny->pullZoneHostnames($pullzone_id);
$bunny->addHostnamePullZone($id, $hostname);
$bunny->removeHostnamePullZone($id, $hostname);
$bunny->forceSSLPullZone($id, $hostname, $force_ssl);
$bunny->addBlockedIpPullZone($pullzone_id, $ip, $db_log = false);
$bunny->unBlockedIpPullZone($pullzone_id, $ip, $db_log = false);
$bunny->listBlockedIpPullZone($pullzone_id);
$bunny->purgeCache($url, $async = false);
$bunny->pullZoneLogs($id, $date);
$bunny->getStatistics();
$bunny->getBilling();
$bunny->balance();
$bunny->monthCharges();
$bunny->monthChargeBreakdown();
$bunny->totalBillingAmount();
$bunny->applyCoupon($code);
$bunny->jsonHeader();
$bunny->convertBytes($bytes, $convert_to = 'GB', $format = true, $decimals = 2);
$bunny->boolToInt($bool);
$bunny->closeConnection();
use Corbpie\BunnyCdn\BunnyAPIStream;
$bunny = new BunnyAPIStream();
$bunny->streamLibraryAccessKey('XXXX-XXXXX-XXXX-XXXX');
//Or set stream library access key at line 14 in BunnyAPI.php
$bunny->setStreamLibraryId($library_id);
$bunny->getVideoCollections();
$bunny->setStreamCollectionGuid($collection_guid);
$bunny->setStreamVideoGuid($video_guid);
$bunny->getStreamCollections($page, $items_pp,$order_by);
$bunny->getStreamForCollection();
$bunny->updateCollection($updated_collection_name);
$bunny->deleteCollection();
$bunny->createCollection($new_collection_name);
$bunny->listVideos($collection_guid);
$bunny->getVideo($collection_guid);
$bunny->deleteVideo($collection_guid);
$bunny->createVideo($video_title);
$bunny->createVideoForCollection($video_title);
$bunny->uploadVideo($video_guid, $video_to_upload);
$bunny->setThumbnail($video_guid, $thumbnail_url);
$bunny->videoResolutionsArray($video_guid);
$bunny->videoSize($video_guid);
$bunny->addCaptions($video_guid, $collection_guid, $label, $captions_file);
$bunny->deleteCaptions($library_id, $video_guid, $srclang);
use Corbpie\BunnyCdn\BunnyAPIDNS;
$bunny = new BunnyAPIDNS();
$bunny->getDNSZones();
$bunny->getDNSZone($zone_id);
$bunny->addDNSZone($domain, $logging);
$parameters = array(
'Domain' => 'zonedomain.com', 'NameserversDetected' => true, 'CustomNameserversEnabled' => true,
'Nameserver1' => 'customns1.com', 'Nameserver2' => 'customns2.com', 'SoaEmail' => '[email protected] ',
'DateModified' => '2022-08-18 23:59:59', 'DateCreated' => '2022-08-18 23:59:59', 'NameserversNextCheck' => '2022-08-28 23:59:59',
'LoggingEnabled' => true, 'LoggingIPAnonymizationEnabled' => true
);
$bunny->addDNSZoneFull($parameters);
$bunny->deleteDNSZone($zone_id);
$bunny->getDNSZoneStatistics($zone_id);
$bunny->updateDNSZoneNameservers($zone_id, $custom_ns, $ns_one, $ns_two);
$bunny->updateDNSZoneNameservers($zone_id, $soa_email);
$parameters = array('Type' => 0, 'Ttl' => 120, 'Accelerated' => true, 'Weight' => 200);
$bunny->addDNSRecord($zone_id, $name, $value, $parameters);
$bunny->addDNSRecordA($zone_id, $hostname, $ipv4);
$bunny->addDNSRecordAAAA($zone_id, $hostname, $ipv6);
$bunny->addDNSRecordCNAME($zone_id, $hostname, $target);
$bunny->addDNSRecordMX($zone_id, $hostname, $mail, $priority);
$bunny->addDNSRecordTXT($zone_id, $hostname, $content);
$bunny->addDNSRecordNS($zone_id, $hostname, $target);
$bunny->addDNSRecordRedirect($zone_id, $hostname, $url);
$bunny->updateDNSRecordA($zone_id, $dns_id, $hostname, $ipv4);
$bunny->updateDNSRecordAAAA($zone_id, $dns_id, $hostname, $ipv6);
$bunny->disableDNSRecord($zone_id, $dns_id);
$bunny->enableDNSRecord($zone_id, $dns_id);
$bunny->deleteDNSRecord($zone_id, $dns_id);
bunnyAPI.php