Skip to content
Quiet Social

The manual builder

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

For a publication written by hand rather than described by a model, SocialPublisher::post() opens a builder that reads like a sentence and ends with a verb: publish, schedule or keep as a draft.

Publishing by hand

use QuietSocial\Social\Facades\SocialPublisher;

SocialPublisher::post()
    ->title('New opening hours')
    ->content('We now open on Sunday mornings.')
    ->link('https://example.com/hours')
    ->tags('Bakery', 'Opening hours')
    ->destinations(['facebook', 'linkedin'])
    ->overrideFor('linkedin', content: 'We now open on Sunday mornings. Details below.')
    ->publish();
Method Effect
title(), content(), link(), tags() The internal title, the text, the link, the tags.
image(Image $image) The image, uploaded when the post is sent.
media(['med_…']) One image already stored by the API, by its identifier.
brand('brd_…') The brand, instead of QUIET_SOCIAL_BRAND_ID.
destinations([...]) Network names (every destination of the network able to publish) or dst_… identifiers. Required.
overrideFor('linkedin', content: …) A text of its own for one network.
reference('article:42'), onBehalfOf($model) Your identifier, and the model to link.
publish(), schedule($date), draft() Sends the publication, and returns the API answer as an array (['data' => [...]]).

Without destinations(), sending throws ValidationFailed (code destinations_required). A post carries one image: media() accepts only one identifier.

From a model

publishSocially() opens the same builder with the reference of the model, and links the publication to the model once the API accepts it. A model that only publishes by hand uses HasSocialPublications and declares the PublishesSocially interface. PublishesToSocial includes the trait; the interface, which a trait cannot carry, is declared on the class when something checks it (the relation manager of the Filament plugin does).

use QuietSocial\Social\Concerns\HasSocialPublications;
use QuietSocial\Social\Contracts\PublishesSocially;

class Workshop extends Model implements PublishesSocially
{
    use HasSocialPublications;
}

$workshop->publishSocially()
    ->content($workshop->summary)
    ->destinations(['facebook'])
    ->schedule(now()->addDay()->setTime(9, 0));

Publications sent this way are linked without a fingerprint: the automatic synchronisation never cancels nor replaces them, and webhooks keep their status up to date like the others.

Errors

The builder throws the exceptions of the SDK: ValidationFailed when the API refuses the post, RateLimited and ServiceUnavailable for a temporary failure worth retrying, AuthenticationFailed or PermissionDenied for the key. Their table, and when to retry, are in the documentation of the PHP SDK.

Without a reference, each call gets a random idempotency key: running a publish() again publishes twice. Give a stable reference() so that a repeated call is recognised.