adulinlin / cloudflare
CloudFlare API - PHP
1.11.3
2019-06-20 09:15 UTC
Requires (Dev)
- phpunit/phpunit: < 6
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2024-09-20 20:42:21 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
功能
当前功能列表包括
使用
在需要跨不同服务多次调用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