ext-curl, ext-json, ext-openssl, ext-simplexml.
Installation
Initializing the Client
Configuration Options
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | — | Merchant API key (stc_live_... or stc_sandbox_...) |
enforcement | EnforcementMode | No | SOFT | How to handle bots without a valid token |
debug | bool | No | false | Enables verbose logging via error_log() |
botDetector | ?BotDetectorInterface | No | null | Custom bot detection logic |
httpClient | ?HttpClientInterface | No | null | Custom HTTP client |
SupertabConnect::resetInstance() if you need to change configuration.
Common Workflows
Handle a Protected Request
handleRequest() manages the full lifecycle — token extraction, verification, bot detection, enforcement, and analytics recording. By default it reads from $_SERVER.
Framework Integration
Pass aRequestContext instead of relying on $_SERVER when using a framework:
Verify a Token and Record Usage
verifyAndRecord() verifies a token and records an analytics event for billing and reporting.
Verify Without Recording
Use the staticverify() for a lightweight validity check with no analytics side effects.
Obtain a License Token
UseobtainLicenseToken() to acquire a token before requesting licensed content. The SDK fetches and parses the publisher’s license.xml, matches the resource URL to a content rule, and exchanges your credentials for a token. Tokens are cached in memory and refreshed automatically before expiry.
Serve the RSL License
UsefetchLicenseXml() to proxy your RSL license from Supertab Connect and serve it at /license.xml on your domain.
Enforcement Modes
| Mode | Behavior |
|---|---|
SOFT (default) | Allows all traffic; attaches X-RSL-Status and Link headers to bot requests missing a token |
STRICT | Blocks bots without a valid token with a 401 and WWW-Authenticate header |
DISABLED | Allows everything unconditionally; no enforcement or signaling |
DISABLED mode.
Result Types
HandlerResult
Returned by handleRequest(). Has two subtypes:
AllowResult—action: ALLOW, plusheadersto set on the responseBlockResult—action: BLOCK, plusstatus(HTTP code),body, andheaders
VerificationResult
Returned by verify() and verifyAndRecord():
| Field | Type | Description |
|---|---|---|
valid | bool | Whether the token is valid for the requested resource |
error | ?string | Human-readable error message when invalid |
Tips
Always apply response headers. The SDK returnsLink and X-RSL-Status headers even on allowed requests in SOFT mode. Apply $result->headers before serving content so crawlers get the correct licensing signals.
Pass RequestContext in frameworks. Relying on $_SERVER directly works for plain PHP, but frameworks often normalize request data before it reaches $_SERVER. Use RequestContext to ensure the SDK reads the right values.
Debug mode logs to error_log(). Enable with debug: true to trace token fetching, license XML parsing, and URL matching.
API Reference
Static Methods
| Method | Description |
|---|---|
verify(token, resourceUrl, ...) | Verify a token without analytics recording |
obtainLicenseToken(clientId, clientSecret, resourceUrl, ...) | Acquire a license token as a crawler client |
fetchLicenseXml(merchantSystemUrn, ...) | Fetch RSL license XML from Supertab Connect |
resetInstance() | Clear the singleton, allowing fresh instantiation |
Instance Methods
| Method | Description |
|---|---|
handleRequest(?RequestContext $context) | Handle a request end-to-end — detection, verification, enforcement, analytics |
verifyAndRecord(token, resourceUrl, userAgent) | Verify a token and record a usage event |