/** * This function will send the SMS using sendsms.pk.API is only for Pakistan's users. * * @param int $to User id * @param string $msg Message Text * @return String $status return will shows the status of message. */ function send_sms($to, $msg) { global $CFG; /* THE SMS API WORK BEGINS HERE */ require_once 'sms_api/sms.php'; $apikey = $CFG->block_sms_apikey; // API Key. $sms = new sendsmsdotpk($apikey); // Making a new sendsms dot pk object. // isValid. if ($sms->isValid()) { $status = get_string('valid_key', 'block_sms'); } else { $status = "KEY: " . $apikey . " IS NOT VALID"; } $msg = stripslashes($msg); // SEND SMS. if ($sms->sendsms($to, $msg, 0)) { $status = get_string('sent', 'block_sms'); } else { $status = get_string('error', 'block_sms'); } return $status; }
</script> </head> <body> <?php if (isset($_POST['a'])) { $to = $_POST['a']; $msg = $_POST['b']; /* THE SMS API WORK BEGINS HERE */ include "sms.php"; $apikey = "f8dfa6472708a1a0f766"; //Your API KEY $sms = new sendsmsdotpk($apikey); //Making a new sendsms dot pk object //TESTING isValid if ($sms->isValid()) { echo "Your key IS VALID"; } else { echo "KEY: " . $apikey . " IS NOT VALID"; } //TESTING SENDSMS if ($sms->sendsms($to, $msg, 0)) { echo "<br /> Your sms is sent to {$to}!"; } else { echo "error ouccured!"; } /* THE SMS API WORK ENDS HERE */ } ?> <form method ="post">