<?php
// GET ?action=sms_countries&api_key=KEY
// Returns list of available countries for SMS verification

try {
    $stmt = $pdo->prepare(
        "SELECT os.id, os.server_name AS country, os.server_code AS code
           FROM otp_server os
           JOIN api_detail ad ON ad.id = os.api_id
          WHERE os.status = '1'
          ORDER BY os.server_name ASC"
    );
    $stmt->execute();
    $countries = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    api_response(['status' => 'error', 'message' => 'Database error.'], 500);
}

api_response([
    'status'    => 'success',
    'count'     => count($countries),
    'countries' => $countries,
]);
