FoPost LogoFoPost Docs
Getting Started (Developers)

Quick Start (Laravel)

Set up FoPost in a Laravel application.

Quick Start - Laravel

This guide gets OwlStack working in your Laravel application in minutes.

1. Install

composer require owlstack/laravel

2. Publish config

php artisan vendor:publish --tag=owlstack-config

This creates config/owlstack.php.

3. Add your API key to .env

OWLSTACK_API_KEY=your-api-key-here

Get your API key from the OwlStack dashboard. Make sure you've connected at least one social media platform via OAuth in the dashboard.

4. Publish content

Via Facade

use OwlStack\Laravel\Facades\OwlStack;
use OwlStack\Enums\Platform;

// Single platform
OwlStack::publish('Hello from Laravel!', [Platform::Telegram]);

// Multiple platforms
OwlStack::publish('Hello from Laravel!', [
    Platform::Telegram,
    Platform::Twitter,
    Platform::LinkedIn,
]);

Via Dependency Injection

use OwlStack\Cloud\OwlStackClient;
use OwlStack\Post;
use OwlStack\Enums\Platform;

class PostController extends Controller
{
    public function publish(OwlStackClient $client)
    {
        $post = Post::create('Hello from Laravel!')
            ->withHashtags(['laravel', 'php']);

        $results = $client->publish($post, [
            Platform::Telegram,
            Platform::Twitter,
        ]);

        foreach ($results as $result) {
            if ($result->isSuccessful()) {
                Log::info("Published to {$result->platform()->value}");
            }
        }
    }
}

5. Check results

$results = OwlStack::publish('Hello!', [Platform::Telegram]);

foreach ($results as $result) {
    $result->isSuccessful();   // bool
    $result->platform();       // Platform enum
    $result->externalId();     // '12345'
    $result->externalUrl();    // URL if available
    $result->error();          // error message if failed
}

6. Listen to events

use OwlStack\Events\PostPublished;
use OwlStack\Events\PostFailed;

Event::listen(PostPublished::class, function (PostPublished $event) {
    Log::info("Published to {$event->result->platform()->value}", [
        'external_id' => $event->result->externalId(),
    ]);
});

Event::listen(PostFailed::class, function (PostFailed $event) {
    Log::error("Failed: {$event->result->error()}");
});

Next steps

On this page