Zactonz PHP SDK
v0.1.0PHP client for the Zactonz APIs: QR codes and barcodes, screenshots and PDFs, social card images, image conversion, link previews, page to Markdown, SSL, DNS, WHOIS, email checks and translation.
Installation
Install with Composer#
composer require zactonz/zactonz-php
The package is zactonz/zactonz-php on Packagist. Composer installs the current release under vendor/zactonz/zactonz-php and registers the Zactonz namespace with your autoloader. Nothing else is required; the library depends only on PHP 8.1 or newer with the curl and json extensions.
Create API keys#
Each Zactonz key works for one product, and the product is part of the key: zk_qr_… is a QR key, zk_screen_… a screenshot key. Create a key for each product you intend to call in the API console. There is a free plan.
Pass every key you have to the client. It picks the right one for each call and throws before any request is made if the key for a product is missing.
$zactonz = new Client(['zk_qr_…', 'zk_screen_…', 'zk_domain_…']);
To keep keys out of your code, put them in the ZACTONZ_API_KEYS environment variable, separated by commas, and call Client::fromEnvironment().
A value that is not a Zactonz key is rejected with InvalidKeyException rather than guessed at. Key values are hidden from var_dump() and stack traces. Keep them on the server; never ship them to a browser.
Check a key#
if ($zactonz->hasKeyFor('screen')) {
$left = $zactonz->keyStatus('screen')->get('quota.day.remaining');
}
keyStatus() calls the API's key check endpoint and returns the plan and the quota remaining today and this month.