Retrieve your iSMS SMS credit balance programmatically using PHP and the iSMS balance API.
Post your credentials as JSON to retrieve the current credit balance. Available for prepaid accounts only — postpaid accounts receive an INVALID ACCOUNT TYPE response.
https://www.isms.com.my/isms_balance_json.php<?php
$payload = [
"un" => "myusername",
"pwd" => "mypassword",
];
$ch = curl_init("https://www.isms.com.my/isms_balance_json.php");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 15,
]);
$raw = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
echo 'Connection error: ' . $err;
exit;
}
$res = json_decode($raw, true);
if (($res['status'] ?? '') === 'success') {
echo 'SMS Credits Remaining: ' . $res['balance'];
} else {
// e.g. -1001 = AUTHENTICATION FAILED
echo 'Error: ' . $res['message'];
}
{ "status": "success", "code": 0,
"username": "myusername",
"balance": "1500" }{ "status": "error", "code": -1001,
"message": "-1001 = AUTHENTICATION FAILED" }-1003.Contact our team — we reply within 1 business day.