From 59e8506a45f02e352c6ac585c827552608cd61ee Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Fri, 19 Jun 2020 14:30:07 +0200 Subject: [PATCH] Edited README --- .gitignore | 5 ++-- README.md | 79 +++++++++++++++++++++++++++--------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 README.md diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 3aa184c..ea1c145 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/.idea -/vendor/ \ No newline at end of file +/.idea +/vendor/ +/nbproject/ diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 1794b7f..6761383 --- a/README.md +++ b/README.md @@ -2,49 +2,48 @@ [![Build Status](https://travis-ci.org/cloudflare/cloudflare-php.svg?branch=master)](https://travis-ci.org/cloudflare/cloudflare-php) -## Installation +See: ([cloudflare/cloudflare-php](https://github.com/cloudflare/cloudflare-php)) -The recommended way to install this package is via the Packagist Dependency Manager ([cloudflare/sdk](https://packagist.org/packages/cloudflare/sdk)). You can get specific usage examples on the Cloudflare Knowledge Base under: [Cloudflare PHP API Binding](https://support.cloudflare.com/hc/en-us/articles/115001661191) +# Cloudflare SDK: added by Shellrent -## Cloudflare API version 4 +- DNS Record is returned on creation: -The Cloudflare API can be found [here](https://api.cloudflare.com/). -Each API call is provided via a similarly named function within various classes in the **Cloudflare\API\Endpoints** namespace: - -- [x] [DNS Records](https://www.cloudflare.com/dns/) -- [x] Zones -- [x] User Administration (partial) -- [x] [Cloudflare IPs](https://www.cloudflare.com/ips/) -- [x] [Page Rules](https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-) -- [x] [Web Application Firewall (WAF)](https://www.cloudflare.com/waf/) -- [ ] Virtual DNS Management -- [x] Custom hostnames -- [x] Manage TLS settings -- [x] Zone Lockdown and User-Agent Block rules -- [ ] Organization Administration -- [x] [Railgun](https://www.cloudflare.com/railgun/) administration -- [ ] [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/) -- [ ] [Origin CA](https://blog.cloudflare.com/universal-ssl-encryption-all-the-way-to-the-origin-for-free/) -- [x] Crypto -- [x] Load Balancers -- [x] Firewall Settings - -Note that this repository is currently under development, additional classes and endpoints being actively added. - -## Getting Started +`Class: Cloudflare\API\Endpoints\DNS` ```php -$key = new Cloudflare\API\Auth\APIKey('user@example.com', 'apiKey'); -$adapter = new Cloudflare\API\Adapter\Guzzle($key); -$user = new Cloudflare\API\Endpoints\User($adapter); - -echo $user->getUserID(); +public function addRecord( + string $zoneID, + string $type, + string $name, + string $content, + int $ttl = 0, + bool $proxied = true, + string $priority = '', + array $data = [] +): \stdClass { + $options = [ + 'type' => $type, + 'name' => $name, + 'content' => $content, + 'proxied' => $proxied + ]; + + if ($ttl > 0) { + $options['ttl'] = $ttl; + } + + if (!empty($priority)) { + $options['priority'] = (int)$priority; + } + + if (!empty($data)) { + $options['data'] = $data; + } + + $user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options); + + $this->body = json_decode($user->getBody()); + + return $this->body->result; +} ``` - -## Contributions - -We welcome community contribution to this repository. [CONTRIBUTING.md](CONTRIBUTING.md) will help you start contributing. - -## Licensing - -Licensed under the 3-clause BSD license. See the [LICENSE](LICENSE) file for details.