Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Balance on Switch (NIC.ch) #390

Open
IIPoliII opened this issue May 30, 2024 · 1 comment
Open

Check Balance on Switch (NIC.ch) #390

IIPoliII opened this issue May 30, 2024 · 1 comment

Comments

@IIPoliII
Copy link

Hello,

I am currently playing around with this code but I don't understand how to use the checbalance function.

Here is my code

<?php
require('../autoloader.php');

use Metaregistrar\EPP\eppConnection;
use Metaregistrar\EPP\eppException;
use Metaregistrar\EPP\eppCheckDomainRequest;
use Metaregistrar\EPP\eppCheckDomainResponse;


echo "Checking balance";
try {
    if ($conn = eppConnection::create('../settings.ini')) {
        $conn->addExtension("balance-1.0", "https://www.nic.ch/epp/balance-1.0");
        // Connect and login to the EPP server
        if ($conn->login()) {
            echo "Checking balance\n";
            checkBalance($conn);
            $conn->logout();
        }
    }
} catch (eppException $e) {
    echo "ERROR: " . $e->getMessage() . "\n\n";
}

function checkBalance($conn) {
    // Create request to be sent to EPP service
    $check = new eppBalanceInfoRequest();
    // Write request to EPP service, read and check the results
    if ($response = $conn->request($check)) {
        $checkResult = $response->getBalance();
        echo $checkResult;
    }
}

Here you can see that I load the "eppCheckDomainRequest".
However when I call eppBalanceInfoRequest using "$check = new eppBalanceInfoRequest();"

I get the following error

PHP Fatal error:  Uncaught Error: Class "eppBalanceInfoRequest" not found in /RED/php-epp-client/Examples/checkbalance1.php:27
Stack trace:
#0 /RED/php-epp-client/Examples/checkbalance1.php(17): checkBalance()
#1 {main}
  thrown in /RED/php-epp-client/Examples/checkbalance1.php on line 27

I am searching since a few hours now, and I would definitly love some help/guidance.

Thanks in advance.

@metaregistrar
Copy link
Owner

It might be that you are missing the import (use Metaregistrar\EPP\eppBalanceInfoRequest)

Or you can try to use the complete path in $check = new Metaregistrar\EPP\eppBalanceInfoRequest();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants