PHP code example of whatdafox / keycdn

1. Go to this page and download the library: Download whatdafox/keycdn 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/ */

    

whatdafox / keycdn example snippets


$keycdn = KeyCDN::create($token);

// List all zones
$keycdn->zones()->all();

// View one specific zone
$keycdn->zones()->find($zoneId);

// Add a zone
$keycdn->zones()->add('foo', 'pull', 'http://foo.com');

// Edit a zone
$keycdn->zone($zoneId)->update([
    'gzip' => 'enabled'
]);

// Delete a zone
$keycdn->zone($zoneId)->delete();

// Purge a zone
$keycdn->zone($zoneId)->purge();

// Purge URLs
$keycdn->zone($zoneId)->purge(['http://foo.com']);
$keycdn->zone($zoneId)->purgeUrls(['http://foo.com']);

// Purge Tags
$keycdn->zone($zoneId)->purge(['http://foo.com'], true);
$keycdn->zone($zoneId)->purgeTags(['http://foo.com']);

// List zone aliases
$keycdn->aliases()->all();

// Add a zone alias
$keycdn->aliases()->add($zoneId, 'cdn.foo.com');

// Edit a zone alias
$keycdn->alias($aliasId)->update([
    'name' => 'cdn.bar.com'
]);

// Delete a zone alias
$keycdn->alias($aliasId)->delete();

// List zone referrers
$keycdn->referrers()->all();

// Add a zone referrer
$keycdn->referrers()->add($zoneId, 'cdn.foo.com');

// Edit a zone referrer
$keycdn->referrer($referrerId)->update([
    'name' => 'cdn.bar.com'
]);

// Delete a zone referrer
$keycdn->referrer($referrerId)->delete();

// Traffic
$keycdn->traffic(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->traffic(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Storage
$keycdn->storage(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->storage(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Status
$keycdn->status(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->status(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Credits
$keycdn->credits(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);