<?php
    // CONFIG
    $BASE_URL   = 'http://wa-api.adfazmedia.com/api/v1/messages';
    $API_KEY    = 'dk_8c662128f21f45b29fbb016862462d2d';
    
    date_default_timezone_set("Asia/Jakarta");
    function SendText($to,$body){
        global $BASE_URL, $API_KEY;
        
        $post_data = [
            'recipient_type'    => 'individual',
            'to'                => $to,
            'type'              => 'text',
            'text'              => [
                                    'body'=> $body
                                   ]
        ];
        
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => $BASE_URL,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_POSTFIELDS => json_encode($post_data),
          CURLOPT_HTTPHEADER => array(
            'Authorization: Bearer '.$API_KEY,
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
    
        curl_close($curl);
        return $response;
    }
?>