PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_SSL_CA => true, // Encapsulated correctly inside the array ] ); } catch (PDOException $e) { // If the database connection drops, immediately return a clean JSON error response header('Content-Type: application/json'); http_response_code(500); echo json_encode([ "error" => "Secure cloud database connection error.", "status" => "fail" ]); exit(); } // ==================================================================== // 3. MEDIA UPLOAD & STORAGE CONFIGURATION (Cloudinary) // ==================================================================== // Pull raw cloudinary:// URL string directly from Vercel's Environment Variables $cloudinary_env = getenv('CLOUDINARY_URL') ?: 'cloudinary://LOCAL_MOCK_KEY_FOR_TESTING'; // Define it as a global constant so your existing media/upload scripts run unchanged define('CLOUDINARY_URL', $cloudinary_env); // ==================================================================== // 4. API UTILITY FUNCTIONS (Optional helper block for your endpoints) // ==================================================================== /** * Standardized function to echo clean JSON responses back to the Instagram app */ function sendJsonResponse($data, $status_code = 200) { header('Content-Type: application/json'); http_response_code($status_code); echo json_encode($data); exit(); }