PHP
Official PHP client for the Zernio API. Install via Composer and publish to 14+ social platforms. Guzzle-based, PHP 8.1+.
The official PHP client for the Zernio API. Built on Guzzle. Requires PHP 8.1+.
- Package:
zernio-dev/zernio-phpon Packagist - Source: github.com/zernio-dev/zernio-php
Install
composer require zernio-dev/zernio-phpUse the Zernio\ namespace. The legacy Late\ namespace is auto-aliased on load for backwards compatibility, so existing code keeps working.
Quick start
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization with your API key
$config = Zernio\Configuration::getDefaultConfiguration()
->setAccessToken(getenv('ZERNIO_API_KEY'));
$postsApi = new Zernio\Api\PostsApi(new GuzzleHttp\Client(), $config);
$twitter = new Zernio\Model\CreatePostRequestPlatformsInner();
$twitter->setPlatform('twitter');
$twitter->setAccountId('acc_xxx');
$linkedin = new Zernio\Model\CreatePostRequestPlatformsInner();
$linkedin->setPlatform('linkedin');
$linkedin->setAccountId('acc_yyy');
$request = new Zernio\Model\CreatePostRequest();
$request->setContent('Hello world from Zernio!');
$request->setPlatforms([$twitter, $linkedin]);
$request->setPublishNow(true);
try {
$result = $postsApi->createPost($request);
print_r($result);
} catch (Zernio\ApiException $e) {
echo 'Exception when calling PostsApi->createPost: ', $e->getMessage(), PHP_EOL;
}Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
For safe retries, createPost accepts an idempotency key as its second argument: $postsApi->createPost($request, $xRequestId). Requests that reuse the same ID within ~5 minutes return the original post instead of double-posting.
List connected accounts
$accountsApi = new Zernio\Api\AccountsApi(new GuzzleHttp\Client(), $config);
$result = $accountsApi->listAccounts();
print_r($result);Error handling
API failures throw Zernio\ApiException, which carries the HTTP status and response body:
try {
$postsApi->createPost($request);
} catch (Zernio\ApiException $e) {
echo 'Status: ', $e->getCode(), PHP_EOL;
echo 'Body: ', $e->getResponseBody(), PHP_EOL;
}See the error handling guide for the API's error codes and retry semantics.
Full reference
The SDK exposes every API namespace as a class in Zernio\Api: PostsApi, AccountsApi, ProfilesApi, AnalyticsApi, QueueApi, MediaApi, WebhooksApi, AdsApi, PhoneNumbersApi, WhatsAppApi, WorkflowsApi, and more. Each method maps 1:1 to an API Reference operation.