Send SMS
This commit is contained in:
@@ -10,6 +10,7 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Exception;
|
||||
use Twilio\Rest\Client;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
@@ -136,8 +137,25 @@ abstract class BaseController extends Controller
|
||||
$password = substr( str_shuffle(sha1(rand() . time()) . $chars ), 0, $length );
|
||||
return $password;
|
||||
}
|
||||
|
||||
public function sendSMS($to_number, $sms_message):string{
|
||||
|
||||
// Find your Account SID and Auth Token at twilio.com/console
|
||||
// and set the environment variables. See http://twil.io/secure
|
||||
$sid = getenv("TWILIO_ACCOUNT_SID");
|
||||
$token = getenv("TWILIO_AUTH_TOKEN");
|
||||
$twilio = new \Twilio\Rest\Client($sid, $token); //Twilio\Rest\Client
|
||||
|
||||
$message = $twilio->messages->create(
|
||||
"+2348141331999", // To
|
||||
[
|
||||
"body" =>
|
||||
$sms_message,
|
||||
"from" => "+14706008089",
|
||||
]
|
||||
);
|
||||
return $message->body;
|
||||
}
|
||||
public function sendSMS_OLD($to_number, $sms_message):string{
|
||||
$API_KEY ="TLYsgMTZBeasJHHimcWXG1QPHmjH7FPwnbKwiqTEwGCu6TrK0v13hCn8N6SYZp";
|
||||
$BASE_URL = "https://api.ng.termii.com";
|
||||
log_message('error', "SMS TO API---=>". $to_number);
|
||||
|
||||
Reference in New Issue
Block a user