1. Go to this page and download the library: Download hansadema/mofh-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hansadema / mofh-client example snippets
use InfinityFree\MofhClient\Client;
$client = new Client("<MOFH API username>", "<MOFH API password>");
use InfinityFree\MofhClient\Client;
$client = new Client("<API username>", "<API password>");
$response = $client->createAccount(
'abcd1234',
'password123',
'[email protected]',
'userdomain.example.com',
'my_plan'
);
if ($response->isSuccessful()) {
echo "Created account with username: " . $response->getVpUsername();
} else {
echo "Failed to create account: " . $response->getMessage();
}
// First suspend the account
$suspendResponse = $client->suspend('abcd1234', 'User requested account deletion');
if (!$suspendResponse->isSuccessful()) {
die("Failed to suspend: " . $suspendResponse->getMessage());
}
// Then remove it
$removeResponse = $client->removeAccount('abcd1234');
if ($removeResponse->isSuccessful()) {
echo "Account removed successfully";
} else {
echo "Failed to remove account: " . $removeResponse->getMessage();
}
$response = $client->createTicket(
'Cannot access my website',
'I am getting a 500 error when I try to visit my website.',
'userdomain.example.com',
'abcd_12345678',
'192.168.1.1'
);
if ($response->isSuccessful()) {
echo "Ticket created with ID: " . $response->getTicketId();
} else {
echo "Failed to create ticket: " . $response->getMessage();
}
$response = $client->availability('newdomain.example.com');
if ($response->isAvailable()) {
echo "Domain is available!";
} else {
echo "Domain is already in use.";
}