<?php

namespace App\Libraries;

class WhatsappService {
    public function send($phone, $message) {
        if (!function_exists('curl_init')) {
            log_message('warning', 'cURL tidak tersedia, WhatsApp notification dilewati.');
            return false;
        }

        $api_key = 'API_KEY_ANDA_DISINI';
        $curl = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL => 'https://api.fonnte.com/send',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => [
                'target' => $phone,
                'message' => $message,
            ],
            CURLOPT_HTTPHEADER => ["Authorization: $api_key"],
        ]);
        $response = curl_exec($curl);
        curl_close($curl);
        return $response;
    }
}