shadowlmd / cloudflare
CloudFlare API - PHP (从jamesryanbell/cloudflare分支而来)
2.0.1
2021-03-10 10:13 UTC
Requires (Dev)
- phpunit/phpunit: < 6
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2024-09-10 18:34:02 UTC
README
https://github.com/cloudflare/cloudflare-php
鉴于Cloudflare已发布官方包,我将继续修复此库的bug,但不会进行进一步的开发。
您可以在此处了解更多关于官方包的信息
- 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