Send request to Direct Admin with create subdomain

feerdispzoo

Verified User
Joined
Jan 17, 2022
Messages
189
I've created in DA custom script. Now when I create subdomain directly in DA panel then is running my script which install WordPress in catalog new subdomain.

Now I need put PHP script in my checkout success page website, which will be triggered and send request to DA with create new subdomain.

Can anyone give me any hint on help me how can I to do?

I have sample code:

PHP:
<?php



include 'httpsocket.php';



$sock = new HTTPSocket;

$sock->connect('localhost',2222);



$sock->set_login("admin|user","admin_password");



$sock->set_method('POST');



$sock->query('/CMD_API_SUBDOMAINS',

        array(

                'action' => 'create',

                'domain' => 'MAINDOMAIN',

                'subdomain' => 'SUBDOMAIN_NAME',

                'create' => 'Create'

    ));



$result = $sock->fetch_body();



?>


But when I try run this code from browser example: myweb.com/cratesubdomain.php then I get below issue:
Code:
Fatal error: Uncaught Error: Class 'HTTPSocket' not found in /home/user/domains/myweb.com/public_html/createsubdomain.php:5 Stack trace: #0 {main} thrown in /home/user/domains/myweb.com/public_html/createsubdomain.php on line 5

Maybe I should put any script in custom script .sh in DirectAdmin ? but if so, how then can I call (tigger) it from browser?

Can anyone review this code for me, will it be properly invoked and get the job done when I put it on the sucess page?
 
Back
Top