PHPackages                             mantix/laravel-social-media-publisher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mantix/laravel-social-media-publisher

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mantix/laravel-social-media-publisher
=====================================

Laravel social media auto post package - Complete solution for publishing to 8 major social media platforms with multi-user support and OAuth integration

v2.1.4(5mo ago)071MITPHPPHP ^8.2

Since Nov 13Pushed 5mo agoCompare

[ Source](https://github.com/Mantix/laravel-social-media-publisher)[ Packagist](https://packagist.org/packages/mantix/laravel-social-media-publisher)[ RSS](/packages/mantix-laravel-social-media-publisher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Laravel Social Media Publisher
==============================

[](#laravel-social-media-publisher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ffdcc720967e773bde76bf5370d2930e05849eb26ac45c450363d4832c110b8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616e7469782f6c61726176656c2d736f6369616c2d6d656469612d7075626c69736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mantix/laravel-social-media-publisher)[![Total Downloads](https://camo.githubusercontent.com/9418358f73ae53680b8bb845df1879c68002dc15b18cd688c261581f5298a269/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616e7469782f6c61726176656c2d736f6369616c2d6d656469612d7075626c69736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mantix/laravel-social-media-publisher)[![License](https://camo.githubusercontent.com/0bb864e18876aecd0400bd2ea5cf4011691b546dc835c87265adb512216923d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616e7469782f6c61726176656c2d736f6369616c2d6d656469612d7075626c69736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mantix/laravel-social-media-publisher)

A production-ready Laravel package for omnichannel social media publishing across **8 major platforms**. Post to one platform or all simultaneously with a unified API, handling complex media uploads (chunked, resumable) automatically.

🌟 Features
----------

[](#-features)

- **8 Supported Platforms**: Facebook, X (Twitter), LinkedIn, Instagram, TikTok, YouTube, Pinterest, Telegram.
- **Polymorphic Connections**: Users, Companies, or *any* Eloquent model can connect their own social accounts.
- **Production Ready Media**:
    - **YouTube**: Resumable Upload Protocol for large video files.
    - **X (Twitter)**: Chunked Media Uploads (INIT -&gt; APPEND -&gt; FINALIZE).
    - **TikTok**: Binary stream uploading via API v2.
    - **Instagram**: Async Container Status Polling for reliable publishing.
- **Unified &amp; Specific APIs**: Use the generic `SocialMedia` facade for bulk posting, or platform-specific facades (e.g., `YouTube`) for deep features like analytics.
- **Security**: Built-in OAuth 2.0 with **PKCE** support (required for X/LinkedIn). Tokens are encrypted at rest.

📊 Supported Features Matrix
---------------------------

[](#-supported-features-matrix)

Not all platforms support all content types via API. This package enforces these limits to prevent API errors.

PlatformText PostLink PostImage PostVideo PostNotes**Facebook**✅✅✅✅Pages only (Profiles deprecated by Meta).**X (Twitter)**✅✅✅✅Video uses chunked uploads.**LinkedIn**✅✅✅✅Personal Profiles &amp; Company Pages.**Telegram**✅✅✅✅Channels &amp; Groups via Bot API.**Pinterest**❌❌✅✅Requires Image/Video. Must select Board.**Instagram**❌❌✅✅Business/Creator Accounts only.**TikTok**❌❌❌✅Strict Video-only API.**YouTube**❌❌❌✅Strict Video-only API.---

🚀 Installation
--------------

[](#-installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require mantix/laravel-social-media-publisher
```

### 2. Publish Configuration &amp; Migrations

[](#2-publish-configuration--migrations)

```
php artisan vendor:publish --provider="Mantix\LaravelSocialMediaPublisher\SocialShareServiceProvider"
php artisan migrate
```

This creates the `social_media_connections` table which stores encrypted access tokens linked to your models.

### 3. Configure `.env`

[](#3-configure-env)

Add your client credentials. **Note:** Telegram uses a Bot Token; all others use OAuth 2.0 Client IDs.

```
# Facebook / Instagram
FACEBOOK_CLIENT_ID=your_app_id
FACEBOOK_CLIENT_SECRET=your_app_secret

# X (Twitter)
X_CLIENT_ID=your_client_id
X_CLIENT_SECRET=your_client_secret

# LinkedIn
LINKEDIN_CLIENT_ID=your_client_id
LINKEDIN_CLIENT_SECRET=your_client_secret

# TikTok
TIKTOK_CLIENT_ID=your_client_key
TIKTOK_CLIENT_SECRET=your_client_secret

# YouTube
YOUTUBE_CLIENT_ID=your_client_id
YOUTUBE_CLIENT_SECRET=your_client_secret

# Pinterest
PINTEREST_CLIENT_ID=your_app_id
PINTEREST_CLIENT_SECRET=your_app_secret

# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
```

---

🔑 Authentication (OAuth Flow)
-----------------------------

[](#-authentication-oauth-flow)

You must create routes to let users connect their accounts. This package handles the complexity of PKCE and Token Exchange automatically.

**Add to `routes/web.php`:**

```
use Illuminate\Support\Facades\Route;
use Mantix\LaravelSocialMediaPublisher\Facades\X;
use Mantix\LaravelSocialMediaPublisher\Facades\LinkedIn;

// 1. X (Twitter) - Requires PKCE
Route::get('/auth/twitter', function () {
    $redirectUri = route('social-media.x.callback');

    // Returns array: ['url' => '...', 'code_verifier' => '...']
    $authData = X::getAuthorizationUrl($redirectUri);

    // IMPORTANT: Store verifier in session for the callback
    session(['x_code_verifier' => $authData['code_verifier']]);

    return redirect($authData['url']);
})->name('social-media.twitter.authorize');

// 2. LinkedIn - PKCE Recommended
Route::get('/auth/linkedin', function () {
    $redirectUri = route('social-media.linkedin.callback');

    $authData = LinkedIn::getAuthorizationUrl($redirectUri, [], null, true); // true = enable PKCE
    session(['linkedin_code_verifier' => $authData['code_verifier']]);

    return redirect($authData['url']);
})->name('social-media.linkedin.authorize');

// ... Repeat for other platforms using their respective Facades
```

**Note:** The callback routes (e.g., `/auth/x/callback`) are **automatically registered** by the package. They handle the token exchange and save the connection to the database linked to the currently authenticated user (`auth()->user()`).

---

📖 Usage
-------

[](#-usage)

### 1. Unified Publishing (The "Share Everywhere" Button)

[](#1-unified-publishing-the-share-everywhere-button)

Use the `SocialMedia` facade to post to multiple platforms at once. Be mindful of platform limitations (e.g., don't send text-only content to TikTok).

```
use Mantix\LaravelSocialMediaPublisher\Facades\SocialMedia;

$user = User::find(1); // The owner of the connections

// A. Text & Link Posts
// Supported: Facebook, X, LinkedIn, Telegram
$textPlatforms = ['facebook', 'twitter', 'linkedin', 'telegram'];
SocialMedia::shareUrl($user, $textPlatforms, 'Check out our new feature!', '[https://example.com/feature](https://example.com/feature)');

// B. Image Posts
// Supported: Facebook, X, LinkedIn, Instagram, Pinterest, Telegram
// Note: YouTube and TikTok will throw exceptions if included here.
$imagePlatforms = ['facebook', 'twitter', 'instagram', 'pinterest'];
SocialMedia::shareImage($user, $imagePlatforms, 'Visual Update', '[https://example.com/image.jpg](https://example.com/image.jpg)');

// C. Video Posts
// Supported: ALL Platforms
// Note: Large videos are automatically chunked/resumed.
$allPlatforms = SocialMedia::getAvailablePlatforms();
SocialMedia::shareVideo($user, $allPlatforms, 'Watch our launch video', '[https://example.com/video.mp4](https://example.com/video.mp4)');
```

### 2. Specific Platform Features

[](#2-specific-platform-features)

Sometimes you need specific features (Analytics, Carousels, Company Pages). Use the `SocialMedia::platform()` factory or the specific Facade with `forConnection()`.

#### 📸 Instagram (Business/Creator)

[](#-instagram-businesscreator)

```
use Mantix\LaravelSocialMediaPublisher\Facades\Instagram;

$user = User::find(1);
$instagram = SocialMedia::platform('instagram', $user);

// Publish Carousel
$instagram->shareCarousel('My Album', [
    '[https://site.com/1.jpg](https://site.com/1.jpg)',
    '[https://site.com/2.jpg](https://site.com/2.jpg)'
]);

// Publish Story
$instagram->shareStoryImage('[https://site.com/story.jpg](https://site.com/story.jpg)');
```

#### 💼 LinkedIn (Profile vs. Page)

[](#-linkedin-profile-vs-page)

```
use Mantix\LaravelSocialMediaPublisher\Facades\LinkedIn;

$user = User::find(1);
$linkedin = SocialMedia::platform('linkedin', $user);

// Post to Personal Profile
$linkedin->shareText('My personal thoughts...');

// Post to Company Page (If connection is set to organization)
// Or use shareToCompanyPage if you have the URN handy
$linkedin->shareToCompanyPage('Official Company Update', '[https://company.com](https://company.com)');
```

#### 📺 YouTube (Resumable Uploads)

[](#-youtube-resumable-uploads)

```
use Mantix\LaravelSocialMediaPublisher\Facades\YouTube;

$user = User::find(1);
$youtube = SocialMedia::platform('youtube', $user);

// Uploads video using Resumable Protocol (handles 1GB+ files)
$youtube->shareVideo('My Vlog', '/local/path/to/video.mp4');

// Get Analytics
$stats = $youtube->getChannelInfo();
```

#### 📌 Pinterest (Boards)

[](#-pinterest-boards)

```
use Mantix\LaravelSocialMediaPublisher\Facades\Pinterest;

$user = User::find(1);
$pinterest = SocialMedia::platform('pinterest', $user);

// Create a specific Pin with destination link
// Note: Pinterest API v5 requires a Board ID
$pinterest->createPin([
    'title' => 'Delicious Recipe',
    'description' => 'Try this out!',
    'link' => '[https://recipes.com/pasta](https://recipes.com/pasta)',
    'media_source' => [
        'source_type' => 'image_url',
        'url' => '[https://recipes.com/img/pasta.jpg](https://recipes.com/img/pasta.jpg)'
    ]
], 'specific_board_id');
```

#### 🎵 TikTok (Videos Only)

[](#-tiktok-videos-only)

```
use Mantix\LaravelSocialMediaPublisher\Facades\TikTok;

$user = User::find(1);
$tiktok = SocialMedia::platform('tiktok', $user);

// Uploads via Binary Stream
$tiktok->shareVideo('Dance challenge!', '[https://site.com/video.mp4](https://site.com/video.mp4)');
```

#### 🐦 X (formerly Twitter)

[](#-x-formerly-twitter)

```
use Mantix\LaravelSocialMediaPublisher\Facades\X;

$user = User::find(1);
$x = SocialMedia::platform('twitter', $user);

// Post Tweet
$x->shareText('Hello World from Laravel!');

// Post Video (Chunked Upload handled automatically)
$x->shareVideo('My Video', '[https://site.com/video.mp4](https://site.com/video.mp4)');
```

---

🛠 Advanced Usage
----------------

[](#-advanced-usage)

### Using the Trait

[](#using-the-trait)

Add the `HasSocialMediaConnections` trait to your User or Company models to easily access their connections.

```
use Mantix\LaravelSocialMediaPublisher\Traits\HasSocialMediaConnections;

class User extends Authenticatable {
    use HasSocialMediaConnections;
}

// Usage
$user->hasSocialConnection('facebook'); // true/false
$connection = $user->getSocialConnection('youtube'); // Returns SocialMediaConnection model
```

### Error Handling

[](#error-handling)

The package throws `Mantix\LaravelSocialMediaPublisher\Exceptions\SocialMediaException` for all known API errors.

```
try {
    SocialMedia::shareText($user, ['twitter'], 'Too long...');
} catch (SocialMediaException $e) {
    // Logs are also automatically written to storage/logs/laravel.log
    return back()->with('error', $e->getMessage());
}
```

### Manual Service Instantiation

[](#manual-service-instantiation)

If you need to manually instantiate a service (instead of using `forConnection()` or `SocialMedia::platform()`), you must call `setCredentials()` after construction:

```
use Mantix\LaravelSocialMediaPublisher\Services\LinkedInService;

// Create instance
$linkedin = new LinkedInService();

// Set credentials
$linkedin->setCredentials($accessToken, $authorUrn);

// Now you can use the service
$linkedin->shareText('Hello LinkedIn!');
```

**Note:** The recommended approach is to use `forConnection()` or `SocialMedia::platform()`, which handle credential setting automatically.

### Disconnecting Social Media Accounts

[](#disconnecting-social-media-accounts)

You can disconnect social media accounts by revoking tokens and deleting connection records:

```
use Mantix\LaravelSocialMediaPublisher\Models\SocialMediaConnection;

// Get a connection
$connection = SocialMediaConnection::where('platform', 'linkedin')
    ->where('owner_id', $user->id)
    ->first();

// Disconnect (revokes token on platform and deletes connection)
$connection->disconnect();

// Or disconnect without revoking token (just delete local record)
$connection->disconnect(revokeToken: false);

// Or use the service directly to revoke a token
use Mantix\LaravelSocialMediaPublisher\Facades\LinkedIn;

LinkedIn::disconnect($accessToken);
```

**Note:** The `disconnect()` method on `SocialMediaConnection` automatically:

1. Revokes the access token on the platform (if supported)
2. Deletes the connection record from your database
3. Handles errors gracefully (e.g., if token is already invalid)

---

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](https://www.google.com/search?q=LICENSE).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

12

Last Release

170d ago

Major Versions

v1.0.0 → v2.0.02025-11-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0220f88ffeeccee7e027b2e4ead4f10938594fe48d2e15d802b1f7b12be64b4?d=identicon)[Mantix](/maintainers/Mantix)

---

Top Contributors

[![Mantix](https://avatars.githubusercontent.com/u/5512138?v=4)](https://github.com/Mantix "Mantix (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mantix-laravel-social-media-publisher/health.svg)

```
[![Health](https://phpackages.com/badges/mantix-laravel-social-media-publisher/health.svg)](https://phpackages.com/packages/mantix-laravel-social-media-publisher)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[metrogistics/laravel-azure-ad-oauth

Provides single-sign-on ability to Microsoft Azure Active Directory enabled apps.

8679.1k1](/packages/metrogistics-laravel-azure-ad-oauth)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
