Laravel
Laravel Usage
Publishing to social media from your Laravel application.
Laravel Usage
Using the facade
use OwlStack\Laravel\Facades\OwlStack;
use OwlStack\Content\Post;
use OwlStack\Enums\Platform;
$post = Post::create('Hello from Laravel!')
->withUrl('https://example.com/hello');
$results = OwlStack::publish($post, [
Platform::Twitter,
Platform::LinkedIn,
]);
foreach ($results as $result) {
echo "{$result->platform()->value}: {$result->status()->value}\n";
}Using dependency injection
use OwlStack\Cloud\OwlStackClient;
use OwlStack\Content\Post;
use OwlStack\Enums\Platform;
class SocialController extends Controller
{
public function share(OwlStackClient $client)
{
$post = Post::create('Published via DI!');
$results = $client->publish($post, [Platform::Twitter]);
return response()->json($results);
}
}Publishing with media
use OwlStack\Content\Post;
use OwlStack\Content\Media;
use OwlStack\Enums\Platform;
$post = Post::create('Check out this photo!')
->withMedia([
Media::fromUrl('https://example.com/photo.jpg'),
// or from a local file:
Media::fromPath(storage_path('app/photo.jpg')),
]);
OwlStack::publish($post, [Platform::Twitter, Platform::Facebook]);Queued publishing
If you enabled queued publishing in the config:
// This dispatches a job instead of publishing immediately
OwlStack::publish($post, [Platform::Twitter]);Or dispatch manually:
use OwlStack\Laravel\Jobs\PublishPost;
PublishPost::dispatch($post, [Platform::Twitter]);Artisan commands
# Check connection status
php artisan owlstack:status
# List connected platforms
php artisan owlstack:platforms
# Publish a quick test post
php artisan owlstack:test --platform=twitter