okwinza/cloudflare-api

Simple yet flexible PHP library for CloudFlare API.

1.0.3 2015-10-14 14:56 UTC

This package is auto-updated.

Last update: 2024-03-28 02:48:00 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version Scrutinizer Code Quality Code Coverage License

A small, compact but flexible API library for popular CDN provider CloudFlare written in PHP.

Supports both HOST and CLIENT APIs.

Docs

CloudFlare Client API documentation
CloudFlare Hosting Provider API documentation

HOW TO

  • Get yourself an API key. You can grab one here.
  • Replace {EMAIL} and {TOKEN} with your real data.
  • Start coding.

Example

You can find some demo code in /examples dir.

But still, here are the basics:

If you want to use CLIENT API then instantiate API object like this:

$cf_api_client = new CF("{EMAIL}","{TOKEN}");

Otherwise just pass your {HOST_KEY} to the constructor:

$cf_api_client = new CF("{HOST_KEY}");

And start making requests:

    $response = $cf_api_client->rec_new(array(
        'z' => 'yoursite.com',
        'name' => 'new.yoursite.com',
        'ttl' => 1,
        'type' => 'A',
        'content' => '1.2.3.4'
    ));

Note: rec_new is a name of api method listed in docs

Also, you can change your current EMAIL/TOKEN/HOST_KEY values at any time without re-creating the object:

$cf_api_client->setEmail($email);
$cf_api_client->setToken($token);
$cf_api_client->setHostKey($host_key);

Installation

You can install cloudflare-api via Composer:

composer require okwinza/cloudflare-api

Or by simple require.

Support

vk: okwinza
email: okwinza@gmail.com