davebugg / jamesryanbell_cf_fork
CloudFlare API - PHP
1.0.0
2024-03-26 12:18 UTC
This package is auto-updated.
Last update: 2024-09-26 13:30:13 UTC
README
https://github.com/cloudflare/cloudflare-php
由于 Cloudflare 已经发布了官方包,我将继续修复错误,但不会对库进行进一步的开发。
您可以在此处了解更多关于官方包的信息
- https://blog.cloudflare.com/cloudflare-php-api-binding/
- https://support.cloudflare.com/hc/en-us/articles/115001661191
CloudFlare API - PHP
API 文档可以在 https://api.cloudflare.com 找到,当 API 添加新功能时,我会尽快更新。如果遗漏了某个功能,请提交一个 pull request。
如果您发现包有问题,请通过 issues 告诉我,但请尽可能提供详细信息,最好包括代码示例、环境信息等。
该包的文档可以在此处查看:https://jamesryanbell.github.io/cloudflare/
安装
应通过 composer 进行安装,有关如何安装 composer 的详细信息,请参阅 https://getcomposer.org.cn/
$ composer require jamesryanbell/cloudflare
功能
当前功能列表包括
- DNS 记录
- 区域
- Web 应用防火墙 (WAF)
- CloudFlare IP
- 用户管理
- 虚拟 DNS 管理
- 组织管理
- Railgun 管理
- 无密钥 SSL
- 原始 CA
- 流量管理器 [BETA]
- 流量控制
用法
在需要跨不同服务多次调用 API 的情况下,首先创建 API 连接,然后将该连接传递给其他服务会更简单,例如。
use Cloudflare\Zone\Dns; // Create a connection to the Cloudflare API which you can // then pass into other services, e.g. DNS, later on $client = new Cloudflare\Api('email@example.com', 'API_KEY'); // Create a new DNS record $dns = new Cloudflare\Zone\Dns($client); $dns->create('12345678901234567890', 'A', 'name.com', '127.0.0.1', 120);
如果您只执行单个操作,则可以在实例化类时直接连接到 API,例如。
use Cloudflare\Zone\Dns; // Create a connection to the Cloudflare API which you can // then pass into other services, e.g. DNS, later on $dns = new Cloudflare\Zone\Dns('email@example.com', 'API_KEY'); $dns->create('12345678901234567890', 'TXT', 'name.com', '127.0.0.1', 120);
页面规则
use Cloudflare\Zone\Pagerules; // Define your targets // Currently you can only specify one URL per page rule but this implementation matches the API // so I am leaving it for now in the assumption they are planning to add multiple targets. $targets = [ [ 'target' => 'url', 'constraint' => [ 'operator' => 'matches', 'value' => 'http://example.co.uk/*' ] ] ]; // Define your actions // Each action is held within it's own array. $actions = [ [ 'id' => 'always_online', 'value' => 'on' ] ]; $pagerules = new Cloudflare\Zone\Pagerules('email@example.com', 'API_KEY'); $pagerules->create($zoneId, $targets, $actions);
许可证
MIT