config = $config; } public function send(string $to, string $message): array { $this->debug_log .= "Attempting to send via Twilio\n"; if (!$this->isConfigured()) { return [ 'success' => false, 'error' => 'Twilio configuration is incomplete', 'debug_log' => $this->debug_log ]; } if (!defined('ALEXR_PRO_PLUGIN_DIR')) { return [ 'success' => false, 'error' => 'PRO plugin is required for SMS functionality', 'debug_log' => $this->debug_log ]; } // Load Twilio SDK require_once ALEXR_PRO_PLUGIN_DIR . 'vendors/twilio/vendor/autoload.php'; try { $client = new Client( $this->config->twilio_sid, $this->config->twilio_token ); $result = $client->messages->create( $to, [ 'from' => $this->config->twilio_phone, 'body' => $message ] ); $this->debug_log .= "Twilio message SID: " . $result->sid . "\n"; return [ 'success' => true, 'result' => [ 'provider' => 'twilio', 'message_id' => $result->sid, 'status' => $result->status ], 'debug_log' => $this->debug_log ]; } catch (\Exception $e) { $this->debug_log .= "Twilio error: " . $e->getMessage() . "\n"; return [ 'success' => false, 'error' => 'Twilio sending failed: ' . $e->getMessage(), 'debug_log' => $this->debug_log ]; } } public function isConfigured(): bool { $twilio_sid = $this->config->twilio_sid; $twilio_token = $this->config->twilio_token; $twilio_phone = $this->config->twilio_phone; return !empty($twilio_sid) && !empty($twilio_token) && !empty($twilio_phone); } public function getDebugLog(): string { return $this->debug_log; } }