apiKey = $apiKey; } public function sendVerificationCode(string $mobile, int $templateId, string $code) { $payload = [ 'mobile' => $mobile, 'templateId' => $templateId, 'parameters' => [ [ 'name' => 'code', 'value' => $code ] ] ]; return $this->sendRequest($payload); } protected function sendRequest(array $parameters) { $headers = [ "Content-Type: application/json", "X-API-KEY: {$this->apiKey}" ]; $ch = curl_init($this->apiUrl); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($parameters), ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); curl_close($ch); if ($err) { return ['success' => false, 'error' => $err]; } $decoded = json_decode($response, true); return [ 'success' => $httpCode === 200, 'httpCode' => $httpCode, 'response' => $decoded ]; } } $sms = new SmsVerification($smsPanel);