timclifford / fastly_crudl
此包已被废弃,不再维护。未建议替代包。
Fastly API 的 PHP 封装器
v2.2.1
2020-12-15 08:48 UTC
Requires
- php: ~7.3
- ext-json: *
- ext-openssl: *
- guzzlehttp/guzzle: ^6.5
Requires (Dev)
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
- vlucas/phpdotenv: ^4.1
- dev-master
- v2.2.1
- v2.2.0
- dev-renovate/phpunit-phpunit-10.x-lockfile
- dev-renovate/vlucas-phpdotenv-4.x-lockfile
- dev-renovate/squizlabs-php_codesniffer-3.x-lockfile
- dev-renovate/phpunit-phpunit-9.x-lockfile
- dev-renovate/vlucas-phpdotenv-5.x
- dev-renovate/php-8.x
- dev-renovate/packagist-guzzlehttp/guzzle-vulnerability
This package is auto-updated.
Last update: 2024-08-23 11:02:59 UTC
README
Fastly API 的 PHP 封装器
需要设置 Fastly API 密钥和服务 ID 环境变量。
例如
export FASTLY_API_KEY="2arxxxxxxxxxxxxxxxxxxxxxxxxRIL" export FASTLY_SERVICE_ID="5CLxxxxxxxxxxxxxxxxxxOoLP"
或存储在 .env
文件中
使用方法
您可以通过 composer 安装此包
composer require ....
通过创建一个新的 Fastly 对象并使用 API 令牌和服务 ID 连接到 Fastly API
use Fastly\Fastly;
...
$fastly_api_key = getenv('FASTLY_API_KEY');
$fastly_service_id = getenv('FASTLY_SERVICE_ID');
$fastly = new Fastly($fastly_api_key, $fastly_service_id);
然后您可以向 API 发送请求。
通用发送请求
您可以定义方法、API 路径并提供选项,这些选项将放入请求体中。
// Get stats $stats = $fastly->send('GET', 'stats?from=1+day+ago'); // Get Keys $keys = $fastly->send('GET', 'tls/private_keys'); // Get Single Key $key = $fastly->send('GET', 'tls/private_keys/2XbVFa2kUN1d4rGDBFYkzp'); // Get Domains $domain = $fastly->send('GET', 'service/'. $fastly_service_id .'/version/1/domain/check_all'); $domains = $fastly->send('GET', 'tls/domains'); // Get activations $activations = $fastly->send('GET', 'tls/activations'); // Get Certificates $certificates = $fastly->send('GET', 'tls/certificates'); $certificate = $fastly->send('GET', 'tls/certificates/1JP0gerEJXIxImRnRLckug'); // Purge all $purge = $fastly->send('POST', 'service/'. $fastly_service_id .'/purge_all');
私钥
$private_keys = $fastly->private_keys; $get_keys = $private_keys->get_private_keys(); $key = $private_keys->get_private_key($id); $new_key = $private_keys->send_private_key($key, $name = '');
证书
$certificates = $fastly->certificates; $certificates->get_tls_certificates(); $certificates->get_tls_certificate("1JP0gerEJXIxImRnRLckug"); $certificates->send_tls_certificate($cert); $certificates->update_tls_certificate($id, $certificate); $certificates->delete_tls_certificate($id);