withHeaders([ 'Content-Type' => 'application/json', 'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181', ]) ->withOptions(Controller::httpClientOptions([], 15.0)); $host = trim((string) ($config['name_fa'] ?? '')); if ($host === '') { $host = trim((string) ($config['name_en'] ?? '')); } if ($host === '') { $host = gethostname(); } $response = $http->post('http://185.231.112.101/api/createsms', [ 'phone' => $to, 'host' => $host, 'text' => trim($message), 'platform' => 'rayegansms', ]); $body = $response->json() ?? $response->body(); $success = $response->successful(); if (is_array($body) && $success) { if (array_key_exists('success', $body) && $body['success'] === false) { $success = false; } elseif (array_key_exists('ok', $body) && $body['ok'] === false) { $success = false; } elseif (isset($body['status']) && in_array(strtolower((string) $body['status']), ['error', 'failed', 'fail'], true)) { $success = false; } } return [ 'success' => $success, 'raw' => $body, ]; } }