Want to know how much credit you still have in CM's prepaid platform? With this API you can very quickly see what you have in your CM Account.
The Account Balance API uses CM's producttokens for authentication. The producttoken can be obtained from the https://gateway.cmtelecom.com application.
The account identifier is the GUID associated with your account. This identifier can be found in the URL of the https://welcome.cmtelecom.com application. Examples:
URL | account identifier |
---|---|
https://welcome.cmtelecom.com/en/2f1e7331-991b-497d-9a32-dd3c2d79c56d | 2f1e7331-991b-497d-9a32-dd3c2d79c56d |
https://welcome.cmtelecom.com/en/d7836eee-3c32-4fbf-8a26-638db93d8f03 | d7836eee-3c32-4fbf-8a26-638db93d8f03 |
https://welcome.cmtelecom.com/en/811283f7-caf1-4155-8422-e918e9ac4221 | 811283f7-caf1-4155-8422-e918e9ac4221 |
Returns the current balance for the supplied logical account.
https://api.cmtelecom.com/accountbalance/v1.0/accountbalance/{accountID}
name | in | description | required | type | format |
---|---|---|---|---|---|
accountID | path | Logical Account ID | true | string | uuid |
X-CM-PRODUCTTOKEN | header | The api key obtained from https://gateway.cmtelecom.com | string | string |
http status | description |
---|---|
200 | OK |
{"Currency": "EUR", "Amount": 84.2601}
field | description |
---|---|
Currency | The currency of your account in ISO4217 Code or empty if the credit is expressed in a number of messages |
Amount | A number with the credit left, in the provided currency or the number of messages if no currency is specified. |
curl -i https://api.cmtelecom.com/accountbalance/v1.0/accountbalance/{accountID} -X GET -H "X-CM-PRODUCTTOKEN: 0000000-0000-0000-0000-000000000000" -H "Content-Type: application/json"
<?php // cURL v7.18.1+ and OpenSSL 0.9.8j+ are required $parameters = array( 'accountID' => 'accountID' ); $url = 'https://api.cmtelecom.com/accountbalance/v1.0/accountbalance/' .$accountID; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), CURLOPT_HEADER => TRUE, CURLOPT_RETURNTRANSFER => true ) ); $result = curl_exec($ch); $HeaderInfo = curl_getinfo($ch); $HeaderSize=$HeaderInfo['header_size']; $Body = trim(mb_substr($result, $HeaderSize)); $ResponseHeader = explode('\n',trim(mb_substr($result, 0, $HeaderSize))); unset($ResponseHeader[0]); $Headers = array(); foreach($ResponseHeader as $line){ list($key,$val) = explode(':',$line,2); $Headers[strtolower($key)] = trim($val); } var_dump( array( 'Body' => $Body, 'Headers' => $Headers )); ?>