completed the send SMS which uses the first client App API key
This commit is contained in:
@@ -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
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user