Skip to contents

Create a Friendly Captcha input for usage in a Shiny UI.

Usage

sfc_output(
  id,
  sitekey = Sys.getenv("captcha_sitekey"),
  lang = "en",
  eu_endpoint = FALSE,
  theme_bs5 = FALSE,
  dark_mode = FALSE
)

Arguments

id

The Friendly Captcha input id

sitekey

The Friendly Captcha sitekey

lang

Language attribute for he Friendly Captcha input. Available values are "en", "fr", "de", "it", "nl", "pt", "es", "ca", "da", "ja", "ru", "sv", "el", "uk", "bg", "cs", "sk", "no", "fi", "lt", "lt", "pl", "et", "hr", "sr", "sl", "hu", "ro", "zh", "zh_TW", and "vi" for English, French, German, Italian, Dutch, Portuguese, Spanish, Catalan, Danish, Japanese, Russian, Swedish, Greek, Ukrainian, Bulgarian, Czech, Slovak, Norwegian, Finnish, Latvian, Lithuanian, Polish, Estonian, Croatian, Serbian, Slovenian, Hungarian, Romanian, Chinese (Simplified), Chinese (Traditional), and Vietnamese respectively.

eu_endpoint

Logical. Use the EU endpoint (FALSE or TRUE). Only for Professional Plans.

theme_bs5

Logical. Use a Bootstrap 5 theme (FALSE or TRUE).

dark_mode

logical. Enable dark mode (FALSE or TRUE)

Value

A Friendly Captcha input for usage in Shiny UI.

Examples

if (interactive()) {
  library(shiny)
  library(ShinyFriendlyCaptcha)

  ui <- fluidPage(
    sfc_output("captcha",
    sitekey = Sys.getenv("captcha_sitekey"),
    lang = "en",
    eu_endpoint = FALSE,
    theme_bs5 = FALSE,
    dark_mode = FALSE
    ),
    shiny::textOutput("result")
  )
  server <- function(input, output, session) {

  captcha_result <- sfc_server(
  id = "captcha",
  secret = Sys.getenv("captcha_secret"),
  sitekey = Sys.getenv("captcha_sitekey"),
  eu_endpoint = FALSE
  )
    shiny::observe({
      output$result <- shiny::renderText(paste0("Captcha result: ",captcha_result()$success))
    })
  }
  shiny::shinyApp(ui, server)
}