Download the PHP package siberfx/facebook-autopost without Composer

On this page you can find all versions of the php package siberfx/facebook-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 facebook-autopost

Facebook Autopost for Laravel

Connect one Facebook Page to your Laravel app and share your models to it — automatically when they go live, or whenever you choose. Posts go to the Page feed through the Graph API as link posts.

Requires PHP 8.4+ and Laravel 12 or 13.

Contents

1. Set up the Facebook app

  1. Create a Business app at https://developers.facebook.com/apps (use the Other or Business type).
  2. Add the Facebook Login product. Under its settings, add your callback URL to Valid OAuth Redirect URIs, exactly as the app will send it, e.g. https://example.com/facebook/callback. Add one per environment.
  3. Copy the App ID and App Secret from Settings → Basic.
  4. Permissions: the connecting account must be an admin of the Page. The app needs pages_show_list, pages_manage_posts and pages_read_engagement. While the app is in Development mode these work for people with a role on the app; for other admins, submit the app for App Review.

"URL Blocked: This redirect failed because the redirect URI is not whitelisted" on Facebook's page means the URL sent is not in Valid OAuth Redirect URIs. Run php artisan route:list --name=facebook-autopost.callback, or set FACEBOOK_REDIRECT_URI to the URL you registered.

2. Install

facebook:install options:

To publish pieces by hand:

.env:

Required: say who may manage Facebook. Connecting, disconnecting, seeing the connection and sharing are all guarded by the manage-facebook-autopost gate. The package denies everyone until your app defines it, for example in AppServiceProvider::boot():

The routes sit behind ['web', 'auth', 'can:manage-facebook-autopost'], and the Livewire actions check the same gate.

3. Connect

Send an admin to route('facebook-autopost.redirect'). After Facebook's consent screen they land on after_connect with one of these query values:

?facebook= Meaning
connected Done.
cancelled The person clicked Cancel on Facebook.
error&reason=… Facebook refused, e.g. a permission that is not granted.
exchange_failed The code could not be exchanged; the reason is in your log. Usually a redirect URI mismatch.
invalid_state The login attempt expired or was replayed. Connect again.
missing_code Facebook came back without an authorization code. Connect again.
not_configured App ID or App Secret missing.

The connection card and <x-facebook-autopost::flash /> turn these into messages for you.

The Page is chosen when connecting: FACEBOOK_PAGE_ID when set, otherwise the first Page the account manages. The Page access token is stored encrypted. Page tokens derived from a long-lived user token do not expire, so the package never refreshes them; if Facebook revokes the app, the status turns expired and you connect again.

connection() asks Facebook (debug_token and the Page's name and picture) at most once every status_cache_ttl seconds (300 by default). isConnected() only checks that a token is stored.

4. Make a model shareable

FacebookPost Notes
make(string $url, string $title) Must be an absolute http(s) URL, or InvalidArgumentException. Non-ASCII paths and hosts are normalised.
->commentary(string $template) The message. Default {title}.
->description(string $text) Kept for parity with the other social packages. Facebook builds the link preview from the page's own Open Graph tags, so this text is not sent.

FacebookPost is immutable: each method returns a copy.

With FACEBOOK_AUTO_POST=true, an Article is queued for Facebook when it is created published or changes from draft to published — once. Editing a published article does not post again. Seeders and Artisan commands do not auto-post (set autopost.in_console to allow it). Mass update() queries and saveQuietly() do not fire model events, so they do not auto-post.

Run a queue worker. The job is dispatched after the database transaction commits, is unique per model while it waits, and retries when Facebook is busy or unreachable (429, 5xx, network). A request Facebook refuses outright (400 with an invalid token, 403 …) fails at once, without retries.

5. Share on demand

share() throws NotConnected, NotShareable (not live), FacebookRequestFailed (Facebook's message, with isUnauthorized() and isPermanent()), or InvalidArgumentException (an invalid URL). A post Facebook accepted without returning its id is recorded as posted with a null post_id.

6. Ready-made UI

Everything is rendered with resources/views/tailwind or resources/views/bootstrap (FACEBOOK_UI_THEME).

7. Events

Event When Properties
Connected A connection is completed Connection $connection
Disconnected The connection is removed bool $revoked
Shared A post went out $shareable, FacebookShare $post
ShareFailed An automatic share gave up $shareableType, $shareableId, $exception
TokenExpiringSoon facebook:check-token found an expired or nearly expired token Connection $connection, int $daysLeft

8. Commands

Schedule facebook:check-token daily if you want an alert before a token expires.

9. Notifications

Messages to Telegram, Slack and/or email when a post goes out, an automatic share gives up, or the token is about to expire. A failing channel never fails the share.

Your own channel implements Siberfx\FacebookAutopost\Contracts\NotificationChannel and is listed under notifications.channels in the config.

10. Headless: no UI

FACEBOOK_UI=false (or facebook:install --headless) registers no views, Blade or Livewire components, and the routes answer JSON only. Use the facade, the events and the JSON endpoints yourself:

11. Configuration reference

Key Env Default Notes
app_id FACEBOOK_APP_ID — Required to connect.
app_secret FACEBOOK_APP_SECRET — Required to connect.
page_id FACEBOOK_PAGE_ID null The first managed Page when empty.
redirect_uri FACEBOOK_REDIRECT_URI null The package callback route when empty.
api_version FACEBOOK_API_VERSION v25.0 Graph API version.
autopost.enabled FACEBOOK_AUTO_POST false
autopost.queue — null Queue name for share jobs.
ui.enabled FACEBOOK_UI true false is headless.
ui.theme FACEBOOK_UI_THEME tailwind tailwind, bootstrap, or a published folder.
notifications.* FACEBOOK_NOTIFY* off See section 9.
status_cache_ttl — 300 Seconds.
expiry_warning_days — 7 Used by facebook:check-token.

12. Troubleshooting

Symptom Cause and fix
URL Blocked … redirect URI is not whitelisted Add the callback to Valid OAuth Redirect URIs exactly.
This Facebook account does not manage the Page … Connect with an admin of the Page set in FACEBOOK_PAGE_ID.
Share fails with Invalid OAuth access token (code 190) The app was removed or the Page token was revoked. Connect again.
Share fails with (#200) … or (#10) … A permission is missing. Check the app's permissions and App Review status.
Status says unknown Facebook could not be asked; the stored name is shown until it can.
Auto-post does nothing FACEBOOK_AUTO_POST=true? A queue worker running? Saved through Eloquent (not a mass update())?

All versions of facebook-autopost with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
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/facebook-autopost contains the following files

Loading the files please wait ...