Skip to content
Quiet Social

Installation and authentication

This documentation is translated from French. Should the two versions differ, the French version prevails.

The SDK installs through Composer, without any dependency, and authenticates with an API key created in the Quiet Social panel: a qsc_… identifier and a qss_… secret.

Requirements

  • PHP 8.2 or later, with the curl and json extensions.
  • No other package: the SDK has no Composer dependency.
  • A Quiet Social workspace and an API key.

Install

composer require quiet-social/php-social

Create a key

Keys are created in the panel, on the Clés API (API keys) page, by the owner or an administrator of the workspace: Créer une clé API (Create an API key), then a name, the brand (or "Tout l'espace de travail", the whole workspace) and the rights. The full walkthrough is in the guide.

The secret is shown once, when the key is created. Keep it in an environment variable or a secrets manager, never in your code.

Build the client

use QuietSocial\Sdk\Client;

$client = new Client(
    clientId: 'qsc_a1b2c3d4e5f6g7h8i9j0k1l2',
    clientSecret: (string) getenv('QUIET_SOCIAL_SECRET'),
);

$me = $client->me();

$me->clientName;                      // the name given to the key
$me->brand?->id;                      // brd_…, or null for a key that covers the whole workspace
$me->can('publications:create');      // true when the key holds this right

me() needs no right: call it first, to find out what the key can do.

Argument Default Note
clientId The qsc_… identifier.
clientSecret The qss_… secret.
baseUrl https://quietsocial.dev/api/v1 Must be https. Plain http is accepted for localhost, 127.0.0.1, [::1], *.localhost and *.test only. Any other address throws InvalidArgumentException.
transport CurlTransport See Testing and transports.
brand null The brd_… brand used by every call that does not name one.

Brand key or workspace key

A key bound to a brand publishes for that brand, without saying anything more.

A key that covers the whole workspace must say which brand it publishes for, or the API refuses the publication (brand_required). Give the brand to the client (new Client(..., brand: 'brd_…')) or to the post (Post::make()->brand('brd_…')). $client->defaultBrand() returns the brand of the client, and $client->brands()->list() the brands the key can see, with their id.

The rights a key needs

Each right is a checkbox on the key. Tick only those your integration uses; each right is detailed in Scopes.

Call Rights
publications()->create() publications:create, destinations:read (targets are resolved first), and media:create when the post has an image to upload
publications()->find(), publications()->list() publications:read
publications()->publish() publications:update
publications()->cancel() publications:cancel
publications()->retry() publications:retry
destinations()->list(), destinations()->all(), destinations()->find() destinations:read
media()->upload(), media()->delete() media:create (media:read as well to upload an Image::existing(), which is read back)
media()->find(), media()->list() media:read
brands()->list() brands:read
webhooks()->list(), webhooks()->create(), webhooks()->update(), webhooks()->delete(), webhooks()->test() webhooks:manage
me() none

A call without the right it needs throws PermissionDenied.

The secret stays secret

The secret never shows in var_dump(), print_r(), var_export() or a stack trace. A client cannot be serialized (LogicException): build it where you use it rather than putting it in a cache or passing it to a queued job.