cloudflare api srv add php


cloudflare api srv add php

嗨,我想做一个脚本,添加一个SRV记录到cloudflare,但不能让它工作:(

<?php
include_once("includes/class_cloudflare.php");
$domain = 'game-panel.dk';
$type = 'SRV';
$name = 'testing';
$content = 'myip';
$ttl = '1';
$mode = '0';
$prio = '5';

$service = '_ts3';
$srvname = 'testing';
$protocol = 'UDP';
$weight = '1';
$port = '10002';
$target = 'testing.game-panel.dk';
$cf = new cloudflare_api("my@email.dk", "mycloudflareapikey");
$response = $cf->rec_new($domain, $type, $name, $content, $ttl, $mode, $prio);
print_r($response);
?>

我得到这样的响应:

stdClass Object ( [request] => stdClass Object ( [act] => rec_new ) [result] => error [msg] => Invalid service value. [err_code] => service- )

我使用这个类:

https://github.com/vexxhost/CloudFlare-API/blob/master/class_cloudflare.php

更新&D

    <?php
    require_once($_SERVER["DOCUMENT_ROOT"]."/cloudflare/class_cloudflare.php");
    $cf = new cloudflare_api("E-Mail", "API Key");
    $domain = "domain.tld";
    $type = "SRV";
    $name = "ts3";
    $content = "1.1.1.1";
    $ttl = "1";
    $mode = "0";
    $prio = "5";

    $service = "_ts3";
    $srvname = "testing";
    $protocol = "_udp";
    $weight = "1";
    $port = "10002";
    $target = "test.domain.tld";
    // Add (SRV) AND (A) RECORD TO CLOUDFLARE.
    $response2 = $cf->rec_new($domain, $type, $name, $content, $ttl, $mode, $prio, $service, $srvname, $protocol, $weight, $port, $target);
    $response = $cf->rec_new($domain, 'A', $name, $content, $ttl, $mode, $service_mode = '1');  
    echo "<pre>";
    print_r($response);
    echo "</pre>";
    echo "<pre>";
    print_r($response2);
    echo "</pre>";  
?>
  1. 必须创建新的区域并注册域名。
  2. 在步骤1之后,您可以创建dns记录…(试试这个https://github.com/Silent-Force/CloudFlare-API)
  3. 必须为请求指定正确的URL地址,并选择request方法。官方文档- https://api.cloudflare.com/