<?php
namespace App\Http\Controllers;
use App\Classes\TransactionGeneration;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class SmsController extends Controller
{
protected $username;
protected $password;
protected $from;
protected $key;
protected $url;
protected $country_code;
protected $country_code_final;
protected $token;
public function __construct()
{
$this->username = "Paytek";
$this->password = "Paytek19";
$this->from = "i.Mali";
$this->key = "Basic MDAwNDp1Yko1eEhNZGhQWEE=";
// $this->url = "https://sislog.me/hubtel/v0/messages/send";
$this->url = "https://lin4.sislog.com/hubtel/v0/messages/send";
$this->country_code = '258';
$this->country_code_final = '+258';
$this->token = new TransactionGeneration();
}
public function sendSms(Request $request): \Illuminate\Http\JsonResponse
{
$transaction = $this->token->generateMSID();
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => "Basic MDAwNDp1Yko1eEhNZGhQWEE="
])->post("https://lin4.sislog.com/hubtel/v0/messages/send", [
'From' => 'Watherver',
'To' => '+258872246236',
'RegisteredDelivery' => 'true',
'Content' => 'a',
'ClientReference' => $transaction,
'Time' => date('Y-m-d H:i:s')
]);
return response()->json($response->json());
}
}