Check your credit

Download the code of the sendget function defined in the file sendhttp.php. Copy the file in the space of your application.

NOTE: See the page Call the service API for a description of the sendget function.

loginYour identification code.
passwordYour password.

Add the file getcredit.php with the following content:

  1. require_once 'sendhttp.php';

Loads the code of the sendget function provided by iZend.

  1. function getcredit($login, $password) {

Defines the function getcredit. $login is your identification code. $password is your password.

  1.     $curl = '';
  2.     $args = array(
  3.         'login'     => $login,
  4.         'password'  => $password,
  5.     );

Sets $curl to the URL of the getcredit action. Fills the array $args with the parameters of the getcredit action.

  1.     $response=sendget($curl, $args);

Sends the HTTP request with sendget.

  1.     if (!$response or $response[0] != 200) {
  2.         return false;
  3.     }

If $response is false, the server is unreachable. If $response[0] doesn't contain the HTTP return code 200 Ok, an execution error has occurred. In case of error, getcredit returns false.

  1.     return $response[2];
  2. }

Returns the body of the response, i.e. the number of credit units of the account.


Assuming you have saved the files sendhttp.php and getcredit.php in the current directory, run PHP in interactive mode, load the getcredit function and call it with your identification code and password in argument:

$ php -a
php > require_once 'getcredit.php';
php > echo getcredit('abcdef', 'ABCDEF');
php > quit

Click on the cart in the menu bar of your home page to buy credit units.


Call the service


To add a comment, click here.