74 lines
1.7 KiB
Markdown
74 lines
1.7 KiB
Markdown
# Usage
|
|
|
|
First, make sure Cap Standalone is installed and running by following [the installation guide](installation.md).
|
|
|
|
Then, you can get to using Cap Standalone:
|
|
|
|
### Client-side
|
|
|
|
Let's configure your widget to use your self-hosted Cap Standalone server. To do this, set the widget's API endpoint option to:
|
|
|
|
```
|
|
https://<instance_url>/<site_key>/
|
|
```
|
|
|
|
Make sure to replace:
|
|
|
|
- `<instance_url>`: The actual URL where your Cap Standalone instance is running. This URL must be publicly accessible from the internet.
|
|
- `<site_key>`: Your site key from this dashboard.
|
|
|
|
Example:
|
|
|
|
```html
|
|
<cap-widget
|
|
data-cap-api-endpoint="https://cap.example.com/d9256640cb53/"
|
|
></cap-widget>
|
|
```
|
|
|
|
### Server-side
|
|
|
|
After a user completes the CAPTCHA on your site, your backend needs to verify their token using this server's API.
|
|
|
|
You can do this by sending a `POST` request from your server to the following endpoint:
|
|
|
|
```
|
|
https://<instance_url>/<site_key>/siteverify
|
|
```
|
|
|
|
Your request needs to include the following data:
|
|
|
|
- `secret`: Your key secret from this dashboard. This is **not** the admin key, but rather your site key's secret.
|
|
|
|
- `response`: The CAPTCHA token generated by the widget on the client-side
|
|
|
|
Example using `curl`:
|
|
|
|
```bash
|
|
curl "https://<instance_url>/<site_key>/siteverify" \
|
|
-X POST \
|
|
-H "Content-Type: application/json" \
|
|
-d '{ "secret": "<key_secret>", "response": "<captcha_token>" }'
|
|
```
|
|
|
|
The response should look like this:
|
|
|
|
```json
|
|
{
|
|
"success": true
|
|
}
|
|
```
|
|
|
|
Or, if the captcha token is invalid or expired, it will return:
|
|
|
|
```json
|
|
{
|
|
"success": false
|
|
}
|
|
```
|
|
|
|
If `success` is true, you can proceed with your app logic.
|
|
|
|
### Client-side library storage
|
|
|
|
To learn more about using the client-side library, check out the [guide on it](options.md#asset-server).
|