cloudflare / cloudflare-php

PHP library for the Cloudflare v4 API
BSD 3-Clause "New" or "Revised" License
621 stars 222 forks source link

Creating a SRV record does not work #67

Closed kruisdraad closed 5 years ago

kruisdraad commented 6 years ago

Ill be submitting a PR linking to this issue, but the SDK is missing code to create and update SRV records and the fix seems simple enough.

In addition, if you change items like proto with a bad value 'tcp' instead of '_tcp' it the API cannot handle the error message and shows %s:

Caught exception: Client error: POST https://api.cloudflare.com/client/v4/zones/xxxxxxx/dns_records resulted in a 400 Bad Request response: {"success":false,"errors":[{"code":1004,"message":"DNS Validation Error","error_chain":[{"code":9150,"message":"%s"}]}],"messages":[],"result":null}

kruisdraad commented 6 years ago

example for documentation:

$srvdata = [ 'weight' => 100, 'priority' => 100, 'proto' => '_tcp', 'port' => 1111, 'target' => 'a.x.c.', 'service' => '_test.v1' ];

if ($dns->addRecord($zoneID, "SRV", '', '', 120, false, '', $srvdata) === true) { echo "DNS record created.". PHP_EOL; }

bohanyang commented 6 years ago

You're right. proto should be _tcp but not tcp. For those who met this issue.