completed the send SMS which uses the first client App API key

This commit is contained in:
Kwesi Banson Jnr
2026-04-05 09:09:04 +00:00
parent 595e7a6531
commit 2064c2d6e5
4 changed files with 39 additions and 34 deletions

View File

@@ -31,6 +31,16 @@ class ApiCalls
}
public static function CurlPost($data, $url){
$post_url = env('APIBASEURL') . $url;
$header_part = '';
$client_id = session('current_user.org_id');
if ($url == 'sms/send') {
// code...
$apps_url = "applications/client/$client_id?page=0&size=20&sort=createdAt,desc";
$result = static::CurlGet($apps_url);
$result_arr = json_decode($result);
$api_key = $result_arr->content[0]->apiKey;
$header_part = "Authorization: Bearer " . $api_key;
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $post_url,
@@ -43,7 +53,7 @@ class ApiCalls
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
'Content-Type: application/json', $header_part
),
));
$response = curl_exec($curl);
@@ -53,6 +63,8 @@ class ApiCalls
public static function CurlPatch($data, $url){
$patch_url = env('APIBASEURL') . $url;
$header_part = '';
$curl = curl_init();
curl_setopt_array($curl, array(
@@ -66,7 +78,7 @@ class ApiCalls
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
'Content-Type: application/json', $header_part
),
));