Skip to main content
The Supertab Connect PHP SDK lets publishers implement RSL license serving and CAP enforcement in PHP applications. It handles token verification, bot detection, enforcement, and — when enabled — analytics for agent & bot classification. Requirements: PHP 8.1+, with extensions 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 a RequestContext 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 static verify() for a lightweight validity check with no analytics side effects.

Obtain a License Token

Use obtainLicenseToken() 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

Use fetchLicenseXml() 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) or 403 Forbidden (token valid but wrong audience).
Invalid tokens are always blocked except in DISABLED mode.

HandlerResult

Returned by handleRequest(). Has two subtypes:
  • AllowResultaction: ALLOW, plus headers to set on the response
  • BlockResultaction: BLOCK, plus status (HTTP code), body, and headers

VerificationResult

Returned by verify() and verifyAndRecord():

Tips

Always apply response headers. The SDK returns Link 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.

API Reference

Static Methods

Instance Methods