- Documentation
- PHP SDK · Version 0.1
- Introduction
Introduction
On this page
The PHP SDK quiet-social/php-social publishes to Facebook, Instagram, LinkedIn, Threads and Pinterest from any PHP application. It talks to the Quiet Social API for you: a post described once, its images uploaded, its targets resolved within the brand, and every refusal turned into a named exception.
A first example
use QuietSocial\Sdk\Client;
use QuietSocial\Sdk\Post;
$client = new Client(
clientId: 'qsc_a1b2c3d4e5f6g7h8i9j0k1l2',
clientSecret: (string) getenv('QUIET_SOCIAL_SECRET'),
);
$publication = $client->publications()->create(
Post::make('Our autumn menu is out.')->link('https://example.com/menu')->reference('menu:autumn'),
to: ['facebook', 'linkedin'],
);
echo $publication->id; // pub_…
The key needs at least the publications:create and destinations:read rights. A key that covers the whole workspace must also name the brand: new Client(..., brand: 'brd_…') (see Installation and authentication).
This call reads the Facebook and LinkedIn destinations of the brand, creates the publication with an idempotency key derived from the reference menu:autumn, and returns the publication as the API stored it.
What the SDK does, and what it leaves to the API
The SDK checks the shape: an absolute link, tags as strings, a title for Pinterest only, no link on Instagram. A shape fault throws InvalidPost before anything is sent.
The API checks the substance: the text length on each network, the number of hashtags, the image Instagram and Pinterest require, the quota of the brand. A refusal of the API throws ValidationFailed, with the reason of each destination.
Everything the SDK does goes through the REST API v1: it opens no door the API does not open, and its rights are those of the key it authenticates with.
The pages of this documentation
- Installation and authentication: requirements, API key, building the client, rights to tick.
- Publishing: describing a post, scheduling, modes, per-network overrides, idempotency, following a publication.
- Images: the four sources of an image, alternative text, the security of remote images.
- Targeting: network names,
dst_…ids, a destination by its name. - Errors: the exception table, and when to retry.
- Webhooks: declaring an endpoint, verifying a notification.
- Testing and transports:
FakeTransport,CurlTransportand custom transports.
Known limitations
- One image per post, and one per network. No gallery, no video.
- X can be declared, not published.
Network::Xexists so that a shared post can already configure it, but the API publishes nothing to X yet:to: ['x']throwsValidationFailedwith the codedestination_unavailable. - No first comment yet.
firstComment()is accepted, but no network publishes one: the API ignores the common one, and refuses one set for a single network. - Network rules are checked by the API, not by the SDK: they are reported by
ValidationFailed, destination by destination. - An idempotency key lives 24 hours. It protects against a retried call, not against a post sent again days later.
Versions
The SDK follows semantic versioning. Before 1.0, a minor version may change the public API; the changelog of the package (CHANGELOG.md) says what changed. This documentation describes version 0.1, which works with version 1 of the API (/api/v1).
The source code is published on GitHub, as a read-only mirror: pull requests are closed there, issues are welcome.