const cuid = [...Array(32)].map(() =>
Math.floor(Math.random() * 16).toString(16)).join('');
import secrets
cuid = secrets.token_hex(16)
import "crypto/rand"
b := make([]byte, 16)
rand.Read(b)
cuid := fmt.Sprintf("%x", b)
$cuid = bin2hex(random_bytes(16));
curl -X POST https://castle.botwitter.com/generate-token \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"cuid": "169c90ba59a6f01cc46e69d2669e080b",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...",
"country": "US"
}'
// Response:
{ "success": true, "token": "eyJhbG...", "cuid": "169c90ba..." }
// Generate random cuid
const cuid = [...Array(32)].map(() =>
Math.floor(Math.random() * 16).toString(16)).join('');
const response = await fetch('https://castle.botwitter.com/generate-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({ cuid, userAgent: navigator.userAgent, country: 'US' })
});
const data = await response.json();
// Response: { success: true, token: "...", cuid: "..." }
import secrets, requests
cuid = secrets.token_hex(16)
response = requests.post(
'https://castle.botwitter.com/generate-token',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={'cuid': cuid, 'userAgent': 'Mozilla/5.0...', 'country': 'US'}
)
data = response.json()
# Response: {"success": True, "token": "...", "cuid": "..."}
import ("crypto/rand", "fmt", "net/http", "bytes")
b := make([]byte, 16)
rand.Read(b)
cuid := fmt.Sprintf("%x", b)
body := fmt.Sprintf(`{"cuid":"%s","userAgent":"Mozilla/5.0...","country":"US"}`, cuid)
req, _ := http.NewRequest("POST", "https://castle.botwitter.com/generate-token", bytes.NewBuffer([]byte(body)))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
// Response: {"success": true, "token": "...", "cuid": "..."}
$cuid = bin2hex(random_bytes(16));
$response = file_get_contents('https://castle.botwitter.com/generate-token', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer YOUR_API_KEY\r\nContent-Type: application/json",
'content' => json_encode(['cuid' => $cuid, 'userAgent' => 'Mozilla/5.0...', 'country' => 'US'])
]
]));
$data = json_decode($response, true);
// Response: ["success" => true, "token" => "...", "cuid" => "..."]