Caputchin
연동 가이드

백엔드 연동 예제

서버 측 연동은 평범한 JSON POST라, 어떤 언어에도 자사 SDK가 없습니다: 당신의 백엔드가 이미 가진 HTTP 클라이언트를 무엇이든 쓰세요. 아래 각 예제는 당신의 시크릿과 폼에서 온 토큰을 보낸 다음, 응답에서 success를 읽습니다. 모두가 시크릿이 코드가 아니라 환경 변수에 있다고 가정합니다.

Node (fetch, 18부터 내장)

const res = await fetch("https://caputchin.com/api/v1/siteverify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ secret: process.env.CAPUTCHIN_SECRET, response: token }),
});
const result = await res.json();
if (!result.success) throw new Error("verification failed");

Python (requests)

import os, requests

res = requests.post(
    "https://caputchin.com/api/v1/siteverify",
    json={"secret": os.environ["CAPUTCHIN_SECRET"], "response": token},
    timeout=10,
)
res.raise_for_status()
if not res.json()["success"]:
    raise RuntimeError("verification failed")

PHP (cURL)

$ch = curl_init("https://caputchin.com/api/v1/siteverify");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "secret" => getenv("CAPUTCHIN_SECRET"),
        "response" => $token,
    ]),
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$result["success"]) throw new Exception("verification failed");

Go (net/http)

body, _ := json.Marshal(map[string]string{
    "secret":   os.Getenv("CAPUTCHIN_SECRET"),
    "response": token,
})
res, err := http.Post("https://caputchin.com/api/v1/siteverify", "application/json", bytes.NewReader(body))
if err != nil {
    return err
}
defer res.Body.Close()
var result struct {
    Success bool `json:"success"`
}
json.NewDecoder(res.Body).Decode(&result)
if !result.Success {
    return fmt.Errorf("verification failed")
}

Ruby (Net::HTTP)

require "net/http"
require "json"

uri = URI("https://caputchin.com/api/v1/siteverify")
res = Net::HTTP.post(
  uri,
  { secret: ENV["CAPUTCHIN_SECRET"], response: token }.to_json,
  "Content-Type" => "application/json",
)
raise "verification failed" unless JSON.parse(res.body)["success"]

.NET (HttpClient)

using var http = new HttpClient();
var payload = JsonSerializer.Serialize(new {
    secret = Environment.GetEnvironmentVariable("CAPUTCHIN_SECRET"),
    response = token,
});
var res = await http.PostAsync(
    "https://caputchin.com/api/v1/siteverify",
    new StringContent(payload, Encoding.UTF8, "application/json"));
var result = JsonSerializer.Deserialize<JsonElement>(await res.Content.ReadAsStringAsync());
if (!result.GetProperty("success").GetBoolean()) throw new Exception("verification failed");

curl (빠른 테스트용)

curl -sS https://caputchin.com/api/v1/siteverify \
  -H "Content-Type: application/json" \
  -d "{\"secret\":\"$CAPUTCHIN_SECRET\",\"response\":\"$TOKEN\"}"

타입 지정된 클라이언트

타입 지정된 클라이언트로 작업하고 싶다면, OpenAPI 생성기를 런타임 API 레퍼런스로 향하게 하세요; /siteverify는 관리 스펙이 아니라 런타임 스펙에 삽니다. 계약이 작으니, 생성된 산출물도 짧습니다.

함께 보기

이 페이지에서