2015-07-19 114 views
0

您好我想作一個腳本,將一個SRV記錄CloudFlare的,但不能讓它的工作:(CloudFlare的API SRV添加PHP

<?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("[email protected]", "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

+0

我現在修復了它 – JonathanNet

+0

請解釋您是如何修復它以造福未來用戶的。 – mjsa

回答

0

更新&完全娛樂添加以下代碼: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>"; 
?> 
+0

我只是在這裏做了這個希望你可以使用它,或者我可以粘貼我的代碼:http://nopaste.php-quake.net/373522 – JonathanNet

+0

糟糕,我沒有看到你的鏈接 – itteam

+0

只是試過它你的,但它仍然不起作用:(我編輯了上面的代碼以包含你的版本 – itteam