xmlapi add SRV record
I'm quite new to this so I'd appreciate some help. I'm currently trying to write a PHP script to create an SRV record for an existing domain name. I receive "Invalid DNS record: Supplied target for SRV record is invalid" with the following code:
$xmlapi = new xmlapi('serverExternalIP');
$xmlapi->password_auth("root","rootpw");
$xmlapi->set_output('json');
$xmlapi->set_debug(1);
print $xmlapi->api2_query("cPanelUserAccount", "ZoneEdit", "add_zone_record", array(
'domain' => 'mydomain.com', #Already an addon domain for the account
'name' => '_minecraft._tcp.test1.mydomain.com', #Took this from a working SRV record I created using the advanced web editor
'type' => 'SRV',
'txtdata' => 'target=server1.mydomain.com,port=25656', #server1.mydomain.com has an existing A record
'ttl' => '300',
'class' => 'IN',)
);
-
Thanks! In hopes of confirming I'm at least doing the basics correctly, I have the following line to dumpzone. Unfortunately, it's not working either. Any idea where I'm going wrong? print $xmlapi->api1_query("cPanelUsernName", "Email", "dumpzone", array($domain));
Output{"apiversion":"1","type":"event","module":"Email","func":"dumpzone","source":"module","data":{"result":""},"event":{"result":1}}
0 -
Hello, Would you mind sharing the full script (minus any actual password hashes) you are using when utilizing the dumpzone WHM API 1 function? I tested with a URL such as: https://10.1.1.1:2087/cpsess9622297555/json-api/dumpzone?api.version=1&domain=cptest01.com
This correctly dumped the zone in the output. Thank you.0 -
Here's the dumpzone script. password_auth("root","rootPass"); $xmlapi->set_output('json'); $xmlapi->set_debug(1); print $xmlapi->api1_query("cPanelUserAccount", "Email", "dumpzone", array($domain)); ?>
0 -
You could try something like this: password_auth("root","password"); $xmlapi->set_debug(1); $xmlapi->set_output('json'); print $xmlapi->dumpzone( $domain );
Thank you.0 -
Thanks, that worked for the dumpzone. Could you provide an example for addzonerecord for an SRV record? Much appreciated. 0 -
You can find examples to use as templates when developing your own custom code at: Thank you. 0 -
Thanks for the examples. Based on the api1 example, I wrote the following code. Unfortunately, it does not seem to be working. Any idea where I'm going wrong? password_auth("root","rootpw"); $xmlapi->set_output('json'); $xmlapi->set_debug(1); print $xmlapi->api1_query("account", "Email", "addzonerecord", array( 'domain' => 'example.com', 'name' => '_minecraft._tcp.test20.example.com', 'type' => 'SRV', 'port' => '25656', 'priority' => '0', 'weight' => '0', 'target' => 'mc1.example.com', 'ttl' => '360', 'class' => 'IN',) ); ?>
Output:{"apiversion":"1","type":"event","module":"Email","func":"addzonerecord","source":"module","data":{"result":""},"event":{"result":1}}
0 -
print $xmlapi->api1_query("account", "Email", "addzonerecord", array(
Hello, I see a few issues with your custom script, but the most notable is you are referencing the "Email" module. You will likely want to consult with a qualified system administrator or developer if you are not comfortable with developing the script on your own. We are happy to offer guidance, but we won't be able to develop each custom script for you. The following option in Web Host Manager is a good way to test the module: "WHM Home " Development " API Shell" Note you must first enable "cPanel & WHM API shell (for developers)" under the "System" tab in "WHM >> Tweak Settings". Thank you.0 -
I appreciate your help and I understand that you're not here to write my script for me, I was just trying to understand the examples for a basic api call. After realizing that there's a great deal of documentation hidden beneath the zmlapi.php file, I was able to get the addzonerecord working. Now my issue is with regards to the name field. It's duplicating the domain name and I'm not sure how to work around this. The API shell did the same thing, so it's probably an issue with my data. 'domain' => 'domain.com', 'name' => '_service._tcp.test20.domain.com',
Yields the following for the record's Name:_service._tcp.test20.domain.com.domain.com.
I've tried removing the 'domain.com' part from the name field but that resulted in an error. Any ideas? Thanks!0 -
The API shell did the same thing, so it's probably an issue with my data.
Hello, The name entry should be:_service._tcp.test20
Thank you.0 -
Thought I tried that... At least it's working now! Thanks again for all of your help! I really appreciate it! :) 0
Please sign in to leave a comment.
Comments
12 comments