添加srv记录cloudflare api

时间:2016-08-08 15:10:06

标签: php api cloudflare srv

删除了隐私的原因。

3 个答案:

答案 0 :(得分:1)

除“type”之外的所有字段都应放入另一个数组调用“data”,尝试将$ post_data修改为

$post_data = array(
        "type" => "SRV",
        "data" => "{"name":"ss2.minefarm.pw","weight":"1","priority":"1","target":"a-ss.minefarm.pw","service":"_minecraft","proto":"_tcp","port":"25565","ttl" :"1"}"
        );

它应该有用。

答案 1 :(得分:0)

当您使用zones端点时,CloudFlare文档会将错误1004列为:Invalid or missing zone。确保您查询的区域ID与CloudFlare在/zones端点中的内容一致。

此外,当您添加DNS记录时,CloudFlare API仅需要以下字段:类型,名称,内容和可选的TTL。虽然CloudFlare Web界面提供了一个为您生成SRV记录值的界面,但在使用API​​时,您需要手动输入您想要存在的记录的值。

在API中,此向导不存在:

Add SRV name record CloudFlare

答案 2 :(得分:0)

我有同样的问题,但现在我有正确的CURL请求。我在FireFox浏览器中单击了SRV所需的所有内容,并使用FireBug观察了对CloudFlare的POST请求。

见下面我的CURL脚本现在对我有用 curl -X POST "https://api.cloudflare.com/client/v4/zones/"$zone_id"/dns_records" \ -H "X-Auth-Email: "$auth_mail \ -H "X-Auth-Key: "$auth_key \ -H "Content-Type: application/json" \ --data '{"zone_name":"example.com","zone_id":"'$zone_id'","type":"SRV","name":"_whatyouwant._tcp.example.com.","content":"SRV 0 0 8080 foo.example.com.","data":{"priority":0,"weight":0,"port":8080,"target":"foo.example.com","service":"_whatyouwant","proto":"_tcp","name":"example.com"},"proxied":false,"proxiable":false,"ttl":300,"priority":1}'