Check your credit
getcredit
GET https://bezillion.com/api/v1/getcredit?login=&password=
login | Your identification code. |
---|---|
password | Your password. |
$ curl -D - -X GET "https://bezillion.com/api/v1/getcredit?login=abcdef&password=ABCDEF"
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.
Add the file getcredit.php with the following content:
- require_once 'sendhttp.php';
Loads the code of the sendget
function provided by iZend.
- function getcredit($login, $password) {
Defines the function getcredit
.
$login
is your identification code. $password
is your password.
- $curl = 'https://bezillion.com/api/v1/getcredit' . '?' . 'login=' . urlencode($login) . '&' . 'password=' . urlencode($password);
Sets $curl
to the URL of the getcredit action of the API with the identification code and the password of the user's account.
$login
and $password
must be escaped.
- $response=sendget($curl);
Sends the HTTP request with sendget
.
The arguments login
and password
are already in $curl
.
- if (!$response or $response[0] != 200) {
- return false;
- }
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.
- $r=json_decode($response[2], true);
Decodes the data returned in JSON.
- if ($r['status'] == 'success') {
- return ($r['data']['credit']);
- }
Returns the number of credit units if the action has succeeded.
- return false;
- }
Returns false
in case of error.
EXAMPLE
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');
10
php > quit
Click on the cart in the menu bar of your home page to buy credit units.
Comments
To add a comment, click here.