ext-curl, ext-json, ext-openssl, ext-simplexml.
Installation
Initializing the Client
Configuration Options
The SDK enforces a singleton pattern per API key. Instantiating with a different key throws an exception. Use
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 event recording (usage always; analytics when analyticsEnabled is set). 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 a usage 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.
Important Types
EnforcementMode
Enforcement modes determine what happens to a bot request. Non-bot traffic is always allowed.
DISABLED: No verification — every request passes through untouched.OBSERVE(Default): Tokens are verified and outcomes recorded. A bot with no token is allowed through with RSL signaling headers (Link,X-RSL-Status) indicating a license is required; a bot presenting an invalid token is still blocked.ENFORCE: Blocks any bot without a valid token —401 Unauthorized(missing or invalid token) or403 Forbidden(token valid but wrong audience).
DISABLED mode.
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():
Tips
Always apply response headers. The SDK returnsLink and X-RSL-Status headers even on allowed requests in OBSERVE 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.