Download the PHP package siberfx/social-autopost without Composer

On this page you can find all versions of the php package siberfx/social-autopost. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package social-autopost

Social Autopost for Laravel

Share your Eloquent models to LinkedIn, X, Facebook, Instagram, TikTok, Mastodon and Bluesky, each one switched on or off on its own, and add more networks later with one class and one config entry.

Requires PHP 8.4+ and Laravel 12 or 13.

Quick start

One post, tailored per network

toSocialPost() builds one post for every network. Tailor it where a network wants other text — hashtags on LinkedIn, tighter copy for X, a caption for Instagram — with on():

Each network gets the override named for it, or the post as it is. The closure runs just before publishing, once per network.

Switching networks on and off

Every network is listed in config/social-autopost.php under networks:

Switch Env (LinkedIn example) Default Meaning
enabled LINKEDIN_ENABLED false Off: hidden everywhere, routes answer 404, sharing and commands refuse it.
autopost LINKEDIN_AUTOPOST false On: queued automatically when a live model is saved. Manual sharing needs no switch.

The env names are LINKEDIN_, X_, FACEBOOK_, INSTAGRAM_ and TIKTOK_ followed by ENABLED or AUTOPOST. A network is only used when it is both switched on and connected.

share() returns one SharedPost per network it tried, posted or failed. When sharing to all, one network's failure is recorded and the others still run.

Setting up each network

Each network needs an app in its developer portal. Register the callback URL of each one you switch on. The default is {your app}/social/{network}/callback; set {NET}_REDIRECT_URI when your URL differs.

Network Developer portal Register this callback Credentials Scopes or permissions
LinkedIn developers.linkedin.com → your app https://example.com/social/linkedin/callback LINKEDIN_CLIENT_ID, LINKEDIN_CLIENT_SECRET Products "Share on LinkedIn" and "Sign In with LinkedIn using OpenID Connect"
X developer.x.com → your app → User authentication settings (OAuth 2.0) https://example.com/social/x/callback X_CLIENT_ID, X_CLIENT_SECRET (optional for a PKCE-only public app) tweet.read tweet.write users.read offline.access (set by the package)
Facebook developers.facebook.com → your app → Facebook Login https://example.com/social/facebook/callback FACEBOOK_APP_ID, FACEBOOK_APP_SECRET pages_show_list, pages_manage_posts, pages_read_engagement; the account must manage the Page
Instagram developers.facebook.com → your app → Instagram → API setup with Instagram login → Business login settings https://example.com/social/instagram/callback INSTAGRAM_CLIENT_ID, INSTAGRAM_CLIENT_SECRET (the Instagram app ID and secret, not the Facebook ones) instagram_business_basic, instagram_business_content_publish; a Business or Creator account
TikTok developers.tiktok.com → your app → Login Kit and Content Posting API (Direct Post on) https://example.com/social/tiktok/callback TIKTOK_CLIENT_KEY, TIKTOK_CLIENT_SECRET user.info.basic, video.publish; verify the domain your media is served from
Mastodon Your instance → Preferences → Development → New application https://example.com/social/mastodon/callback MASTODON_INSTANCE (e.g. https://mastodon.social), MASTODON_CLIENT_ID, MASTODON_CLIENT_SECRET read:accounts write:statuses write:media; no app review, and the token does not expire
Bluesky bsky.app → Settings → Privacy and security → App passwords None: no OAuth app and no consent screen. "Connect" signs in on the server. BLUESKY_IDENTIFIER (handle or email), BLUESKY_APP_PASSWORD (BLUESKY_SERVICE for another PDS) —

Optional settings per network: LINKEDIN_VISIBILITY (PUBLIC or CONNECTIONS), LINKEDIN_API_VERSION, LINKEDIN_ORGANIZATIONS (also post as organization pages, see Choosing pages), FACEBOOK_PAGE_ID (the Page selected after connecting; the first managed Page when empty), FACEBOOK_API_VERSION.

X text is composed to 280 characters and Mastodon statuses to 500, counting every URL as 23. LinkedIn escapes characters it reserves for mentions and hashtags. Facebook sends the link in its own field and takes the preview from the page's Open Graph tags. MASTODON_VISIBILITY sets who sees Mastodon statuses (public, unlisted, private or direct). Bluesky posts carry the link as an embed card — title, description and the post's image as its thumbnail — so the 300-character text is the title and description, or your commentary as written when it fits.

Posting media

Give the post an image or a video as a public URL, and every network posts what it supports:

Network Image Video
LinkedIn Uploaded and posted as an image post, the commentary as its text Not yet: the link is posted instead
X Uploaded and posted with the text. Needs the media.write scope: accounts connected before it was asked post the text alone until they reconnect. Not yet: the text is posted alone
Facebook A Page photo, the commentary as its message (a photo post has no link field, so the link rides in the text) A Page video, the commentary as its description
Instagram Posted (JPEG) A Reel
TikTok A photo post A video
Mastodon Uploaded and attached to the status Not yet: the link is posted instead
Bluesky Uploaded as the link card's thumbnail Not yet: the card is posted without one

Facebook, Instagram and TikTok download the media from its URL themselves; for LinkedIn and X your server downloads and uploads it (http.upload_timeout seconds).

Instagram and TikTok: posts need media

Instagram and TikTok post images and videos, not links; the commentary becomes the caption. A post without media fails on these two networks with a clear message and is not retried; the others still post. Links in captions are not clickable on either network.

Connecting

Send an admin to route('social-autopost.redirect', 'linkedin'). The callback returns them to routes.after_connect with ?social=linkedin&state=connected (or cancelled, error, exchange_failed, invalid_state, missing_code, not_configured).

Choosing pages

LinkedIn and Facebook can post to more than one place. After connecting, the connection lists every page the account can post to, and people choose one or more of them. Every share then goes to each selected page, with one history row per page.

Network Pages
LinkedIn The member's own profile, plus the organization pages they administer when LINKEDIN_ORGANIZATIONS=true
Facebook Every Page the account manages
X, Instagram, TikTok One account; pages is empty

Right after connecting, the selection is what the package posted to before pages existed: the LinkedIn profile, and on Facebook the FACEBOOK_PAGE_ID Page (or the first managed Page). So nothing changes until someone picks other pages.

The pages in the response

GET /social/connections, Social::connection('linkedin')->toArray() and the Connected event's connection all carry the pages. Each page has a selected flag, and selected_pages lists the ids:

type is member (a LinkedIn profile), organization (a LinkedIn organization page) or page (a Facebook Page). Page tokens never leave the server.

Choosing them

Over HTTP, behind the same gate as the other routes. Both answer 404 for a network without pages:

Route Does
GET /social/{network}/pages (social-autopost.pages.show) {"data": {"pages": [...], "selected_pages": [...]}}
PUT /social/{network}/pages (social-autopost.pages.update) Body {"pages": ["urn:li:organization:1042", "urn:li:person:8kX2…"]}: one or more ids. Answers the connection, or 422 when the list is empty or names an unknown page. A plain HTML form is redirected back with a message.

Or in PHP:

The connection cards show a "Post to" list of checkboxes when there is more than one page, and the Livewire card saves it without a page reload. A signed share request may send pages[] to post to other pages for that one share (POST /social/{network}/share), and social:share takes --page= (repeatable). social:status lists each network's pages and marks the selected ones.

When one page fails, the others still post: the failure is recorded for that page, and the share throws only when every page failed. A queued share retries only the pages that have not posted yet.

LinkedIn organization pages

Posting as an organization needs LinkedIn's Community Management API product on your app, which LinkedIn approves on request. Once it is approved, switch it on:

The login then also asks for r_organization_admin and w_organization_social (networks.linkedin.organization_scopes), and connecting lists the pages where the member is an administrator or content administrator. Reconnect after switching it on. Leave it off without the product: LinkedIn refuses a login that asks for scopes the app does not have. If LinkedIn will not list the organizations, the connection still works with the profile only, and a warning is logged.

Facebook Pages

Every Page the account manages is kept, each with its own Page token, so you can post to several Pages from one connection. FACEBOOK_PAGE_ID now only sets the Page selected after connecting; it must still be a Page the account manages.

Upgrading to 1.2

Publish and run the new migration. It adds a target column to social_posts, which records the page each share went to:

Existing connections keep working without reconnecting: a stored LinkedIn connection has the profile as its only page, and a stored Facebook connection has its one Page. Reconnect to list more pages. Until the migration runs, shares still work, but the page is not recorded and a retried job cannot tell which pages already posted. A custom network that implements Contracts\HasPages gets the same page handling as LinkedIn and Facebook.

A ready-made connections page

The command writes resources/views/social/connections.blade.php. The page has one card for every enabled network and a "Developer setup" table with each network's callback URL and auto-post switch. Add a route for it and send people back to it after connecting:

Without --layout, the page is standalone and loads Tailwind or Bootstrap from a CDN. After that, the page is your file to change.

Cards show a short note where a network needs one. Instagram and TikTok say a post needs media, and TikTok mentions private-only posting until it audits your app. Set networks.{key}.hint to replace a note, or '' to hide it. Instagram cannot be revoked through its API, so its disconnect question and message tell people where to remove the app. Use networks.{key}.disconnect_note for your own network.

React and Vue

The cards and share buttons are also available as data, for pages built in React or Vue. Ready-to-copy components, in TypeScript with Tailwind, are in examples/: SocialConnections (one card per enabled network) and ShareButton (shares one model now), for both React and Vue.

1. Copy the components into your app:

2. Build the props on the server with SocialProps. It never includes tokens, and share URLs are signed for their model:

Set routes.after_connect to '/admin/social', so the network sends people back to the page after they connect.

3a. Use them in React:

3b. Use them in Vue:

Without Inertia (a React or Vue app served by the same Laravel app), render the page component without props: <SocialConnections />. It loads the cards from GET /social/connections itself. The share button still needs its signed URL from the server, so include SocialProps::share($post) in the JSON your page already loads for that model. Each card looks like this:

LinkedIn and Facebook cards also have connection.pages, connection.selected_pages and urls.pages; selectPages(card, ids) in social.ts saves a choice. See Choosing pages.

Connecting is a full page load (urls.connect is a plain link). Disconnecting and sharing are JSON requests that send the session cookie and XSRF-TOKEN. See examples/README.md for the details.

Auto-post

When a model is saved and isLiveForSocial() turns true, the observer queues one job per network that is enabled, has autopost on, is connected, and has not already posted the model. Jobs run after the database commit, are unique per model and network while queued, and retry only on 429, 5xx or no answer. Seeders and Artisan commands do not auto-post unless autopost.in_console is true.

Give a network with a small posting quota a rate limit, and queued shares wait their turn instead of failing — an import or backfill then trickles out instead of burning the quota at once:

A job the rate limit sends back to the queue spends one of its job.tries per round trip; set job.retry_for (seconds) to give jobs time instead of tries.

Scheduling a share

shareAt() queues the share for a moment instead of now:

The job checks again when the time comes: a model no longer live, a network switched off or disconnected since, or a model that already posted there post nothing. The history records these shares with the scheduled trigger.

Share history

Every share, posted or failed, is one row in social_posts. Keep it from growing forever by setting prune_after_days and scheduling Laravel's pruner:

A pruned share is forgotten: wasPosted() no longer sees it, and sharing the model again posts again.

Commands

Command Does
social:install [--theme=] [--headless] Publishes config and migrations, sets the UI theme, prints the redirect URI of each enabled network.
social:page [--theme=] [--layout=] [--section=] [--livewire] [--view=] [--force] Writes a connections page with a card for every enabled network.
social:status Every network: enabled, auto-post, connected, status; then each network's pages, the selected ones marked [x].
social:doctor [--ping] Checks the setup where it usually goes wrong: credentials, the callback URL to register, connections and expiry (--ping asks the networks), the gate, the tables, the queue and the notification channels. Exit code 1 when something cannot work.
social:disconnect {network} [--force] Revokes and forgets one connection. Refuses a switched-off network.
social:share {network} {model} {id} [--page=*] [--force] Shares one model to one network now: to its selected pages, or to the --page ids given.
social:retry [network] [--since=] [--dry-run] Queues the failed shares that never posted, so they are tried again. A failure whose model has since posted there is left alone.
social:check-token [--days=] Fires TokenExpiringSoon for enabled networks expiring within expiry_warning_days. Runs by itself on your app's scheduler, daily at 08:00 (check_token_schedule, null to schedule it yourself).
social:test-notification [--channel=] Sends a test to the enabled notification channels.

Notifications

Set SOCIAL_NOTIFY=true and one or more channels:

Every message names the network, for example "Shared on X: …" or "The Facebook token expires in 5 days".

Adding a network

  1. Write a class implementing Siberfx\SocialAutopost\Contracts\SocialNetwork: key(), label(), isConnected(), connection(), beginConnection(), completeConnection(), disconnect() and publish(). Keep its tokens in the ConnectionStore, and read its settings from config('social-autopost.networks.{key}').
  2. Add an entry under networks with enabled, autopost, class and its own keys.
  3. Optionally add post_url (with {id}) for links in notifications, and brand for its colour and logo.
  4. If the account can post to several places, also implement Contracts\HasPages: pages(), selectedPages(), selectPages() and publishToPage(). The page routes, cards, commands and per-page history then work for it too.

Upgrading from the standalone packages

This package replaces siberfx/linkedin-autopost, siberfx/x-autopost and siberfx/facebook-autopost. The data and settings differ in these ways:

Translations

Every text people see — cards, buttons, flash messages, notifications — follows the app locale. English ships built in; publish the lines to translate them:

Headless

Set SOCIAL_UI=false to ship without views or components. Routes then answer JSON only, and you use the facade, events and commands yourself.

Events

Each event carries the network key: Connected, Disconnected, Shared, ShareFailed and TokenExpiringSoon.

Configuration reference

Key Purpose
networks.{key}.enabled, .autopost, .class The switches and the driver.
networks.{key}.* The network's own keys (credentials, API version, page id…).
networks.linkedin.organizations, .organization_scopes Also list and post to the member's organization pages (needs the Community Management API).
networks.{key}.post_url, .brand Notification links and the UI colour and logo.
networks.{key}.hint, .disconnect_note The card note, and what disconnecting means when the network cannot revoke ('' hides).
connection_store Where connections are kept (encrypted, DatabaseConnectionStore by default).
routes enabled, prefix (social), name, middleware, after_connect.
autopost in_console, queue_connection, queue.
ui enabled (headless when false), theme.
notifications enabled, events, queued, tries, backoff, channels.
networks.{key}.rate_limit ['posts' => n, 'per_seconds' => s]: queued shares over it wait their turn.
job tries, backoff, unique_for and retry_for of the auto-post job.
expiry_warning_days, check_token_schedule, prune_after_days, status_cache_ttl, http.timeout Tuning.

Tests

License

MIT. See LICENSE.


All versions of social-autopost with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.8
illuminate/auth Version ^12.0|^13.0
illuminate/bus Version ^12.0|^13.0
illuminate/cache Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/encryption Version ^12.0|^13.0
illuminate/events Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/log Version ^12.0|^13.0
illuminate/mail Version ^12.0|^13.0
illuminate/queue Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/session Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/view Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package siberfx/social-autopost contains the following files

Loading the files please wait ...