CiFrame - the company specializes in the implementation, integration and communication of a variety of web products and platforms. Such products can be CRM, ERP, CMS, as well as payment services, statistics, messaging, mailings (SMS, mail), deliveries, social networks, as well as products in which the API is implemented in one form or another.
Set up the AlphaSMS library in CodeIgniternCreate the AlphaSMS.php library
In the application/libraries/ folder, create the AlphaSMS.php file and paste the following code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class AlphaSMS {
private $api_url = "https://alphasms.ua/api/json";
private $api_key;
public function __construct($params = array()) {
$this->api_key = $params['api_key'] ?? 'ВАШ_API_КЛЮЧ';
}
public function send_sms($phone, $message, $sender = 'AlphaSMS') {
$data = array(
"key" => $this->api_key,
"phone" => $phone,
"message" => $message,
"sender" => $sendern
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
} ?>
Using the library in the controller
In the controller (application/controllers/SmsController.php) add:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class SmsController extends CI_Controller {
public function send() {
$this->load->library('AlphaSMS', array('api_key' => 'ВАШ_API_КЛЮЧ'));
$phone = '+380XXXXXXXXX'; // Введите номер телефонаn $message = 'Ваш код подтверждения: 123456';
$response = $this->alphasms->send_sms($phone, $message);
echo "<pre>";
print_r($response);
echo "</pre>";
}
} ?>
To connect the integration you will need:
If necessary, we will help you obtain all the necessary data.