'error', 'message' => 'Application Key, Secret Key and Region are required'])); } // Test Huawei Cloud API - List ECS instances $host = "ecs.$region.myhuaweicloud.com"; $uri = "/v1/cloudservers"; $method = "GET"; $date = gmdate('Ymd\THis\Z'); $datestamp = gmdate('Ymd'); // Simplified test - just check if we can reach the endpoint $url = "https://$host$uri"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); curl_close($ch); if ($error) { die(json_encode(['status' => 'error', 'message' => 'Connection error: ' . $error])); } // Huawei returns 401 if credentials are wrong, 403 if no auth header // Any response means the endpoint is reachable if ($http_code == 401 || $http_code == 403) { // Endpoint reachable, credentials format seems ok die(json_encode(['status' => 'success', 'message' => "Connection to Huawei Cloud ($region) successful! Endpoint reachable."])); } elseif ($http_code == 200) { die(json_encode(['status' => 'success', 'message' => "Connection successful! API responded correctly."])); } else { die(json_encode(['status' => 'error', 'message' => "Unexpected response (HTTP $http_code). Check your region."])); }