Skip to content
Quiet Social

Targeting

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

The to: parameter of publications()->create() says where to publish: network names, destination ids, or both. The SDK resolves them within the brand before anything is sent, and refuses a target that leads nowhere.

Network names and ids

use QuietSocial\Sdk\Network;

$client->publications()->create($post, to: [
    'facebook',                           // every Facebook destination of the brand that can publish
    Network::LinkedIn,                    // the same, with the enum
    'dst_01k4b8x2q9r7f3m5t6v8w0y2z4',     // this destination, provided it can publish
]);
  • A network name (facebook, instagram, linkedin, threads, pinterest, or a Network case) targets every destination of that network in the brand that can publish. Case does not matter; an unknown name throws InvalidPost.
  • A destination id (dst_…) targets that destination only, provided it belongs to the brand and can publish.
  • The order of the targets does not matter: the same targets in another order make the same publication, and the same idempotency key.

A destination by its name

When a network has several destinations in the brand, several Pinterest boards for instance, destination() narrows the network name to the one with that name:

use QuietSocial\Sdk\Network;
use QuietSocial\Sdk\NetworkPost;

$post = $post->for(Network::Pinterest, fn (NetworkPost $pin) => $pin->destination('Recipes'));

$client->publications()->create($post, to: ['pinterest']);

The name is compared ignoring case (accented letters included) and the surrounding spaces. It is not sent with the request: it only selects the destination.

When a target leads nowhere

The destinations of the brand are read once, every page of them, before any image is uploaded or anything is created. The SDK then throws ValidationFailed, and sends nothing to POST /publications:

Code Cause
destination_unavailable No destination of that network can publish in the brand, none has the requested name, or the dst_… id does not exist in the brand or cannot publish.
destination_ambiguous Several destinations of the network have the requested name: target one of them by its id.

The status of these exceptions is 0, since the API answered nothing, and errors holds the message under the key to. A destination that can no longer publish (a connection to restore, a disabled destination) is fixed in the panel.

to: ['x'] throws destination_unavailable too: Network::X can be declared in a post, but the API publishes nothing to X yet.

Reading destinations

To see what a brand can publish to, and what each destination accepts:

foreach ($client->destinations()->all() as $destination) {
    $destination->id;                              // dst_…
    $destination->network;                         // pinterest
    $destination->name;                            // Recipes
    $destination->canPublish;
    $destination->capabilities->maximumTextLength;
    $destination->capabilities->requiresMedia;
}

destinations()->all() reads every page; destinations()->list() reads one (page, perPage up to 100) and returns a Page; destinations()->find() reads one destination. Capabilities are described in Brands and destinations.

Brands

Targeting always happens within a brand: the one of the key or, for a key that covers the whole workspace, the one of the post (brand()) or of the client (the brand argument). Without a brand, a workspace key reads the destinations of all its brands and the API refuses the publication. brands()->list() returns the brands the key can see.