crasmedia/cloudflare-4

PHP 包用于下一代 CloudFlare API

0.0.2 2017-02-02 08:38 UTC

This package is not auto-updated.

Last update: 2024-09-23 16:11:33 UTC


README

一个用于下一代 CloudFlare API 的 PHP 包。

使用概述

// Set up the request Factory
$factory = new RequestFactory();
$factory->setEmail('FooEmail');
$factory->setKey('FooKey');

// Make a request
$request = $factory->make();
// And run a response
$response = $request->zoneList();

// Alternately, `$response = $factory->zoneList();` does the same thing.

if (!$response->didSucceed()) {
    var_dump($response->getErrors());
    die('Something went wrong!');
} else {
    var_dump($response->getData());
}

可用方法

您可以传递参数,或者简单地将关联数组作为第一个参数传递,其中键是参数名称,值是对应的值。示例

$factory->dnsGet('a', 'b');
// is the same as...
$factory->dnsGet([['zone_id' => 'a', 'dns_id' => 'b']]);

这可能更适合具有非常长的参数列表的函数。

  • ResponseInterface zoneCreate(mixed $name, bool $jump_start = null, array $organization = null)
  • ResponseInterface zoneList(mixed $name = null, string $status = null, integer $page = null, integer $per_page = null, string $order = null, string $direction = null, string $match = null)
  • ResponseInterface zoneGet(mixed $id)
  • ResponseInterface zonePause(mixed $id)
  • ResponseInterface zoneResume(mixed $id)
  • ResponseInterface zonePurge(mixed $id, bool $purge_everything)
  • ResponseInterface zonePurgeFiles(mixed $id, array $files = null)
  • ResponseInterface zoneDelete(mixed $id)
  • ResponseInterface plansList(mixed $zone_id)
  • ResponseInterface plansGet(mixed $zone_id, string $plan_id)
  • ResponseInterface plansSet(mixed $zone_id, string $plan_id)
  • ResponseInterface dnsCreate(mixed $zone_id, string $type = null, string $name = null, string $content = null, integer $ttl = null)
  • ResponseInterface dnsList(mixed $zone_id, string $name = null, string $content= null, string $vanity_name_server_record = null, integer $page = null, integer $per_page = null, string $order = null, string $direction = null, string $match = null)
  • ResponseInterface dnsGet(mixed $zone_id, string $dns_id)
  • ResponseInterface dnsUpdate(mixed $zone_id, string $dns_id, array $__data__)
  • ResponseInterface dnsDelete(mixed $zone_id, string $dns_id)

有关特定函数的更多信息,请参阅 CloudFlare 文档。所有这些返回 ResponseInterface 的实例,它实现了以下方法

  • array getData() - 返回 CloudFlare 响应中的 "results" 数组。
  • mixed getErrors() - 返回 CloudFlare 响应中的 "errors" 数组。
  • bool didSucceed() - 返回 CloudFlare 响应的 "success",true 或 false。