Retrieve the number of credits on an account
This API returns the remaining credit on an account or sub-account.
The endpoint is: https://www.eml-srv.com/_api_rest/api_sms_credits
Authentication
The API uses the REST format and is accessed through HTTP Basic authentication.
How authentication works
If your username is “monlogin” and your password is monmotdepasseABC,
you must build the following string: monlogin:monmotdepasseABC
Then encode it in base 64: bW9ubG9naW46bW9ubW90ZGVwYXNzZUFCQw==
The following property must be added to your HTTP header:
“Authorization” : “Basic bW9ubG9naW46bW9ubW90ZGVwYXNzZUFCQw==”
PHP example with cURL
cURL makes HTTP Basic authentication easy to handle:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.eml-srv.com/_api_rest/api_sms_credits');
curl_setopt($ch, CURLOPT_USERPWD, "monlogin:motdepasse");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$output = curl_exec($ch);Handling the response
The response is in JSON format.
On error
{"Message":"error message detail"}The possible errors are:
- Auth protocol error: the login or password is not set, or the protocol is incorrect
- Auth error: the protocol is correct but the credentials are wrong
- Unknown error - no id: internal system error
On success
The number of credits is returned in the “credits” variable.
Example: {“credits”:“3543”}
Last updated on