This package provides a Twitter channel for Laravel notifications, allowing you to send tweets from your application.
Hi there! If you're using this package, please consider supporting me on GitHub Sponsors. It would mean a lot to me.
You can install the package via composer:
composer require claraleigh/autotweet-for-laravel
You can publish and run the migrations with:
php artisan vendor:publish --tag="autotweet-for-laravel-migrations"
php artisan migrate
Update your user model's casts to include the twitter_token
field:
$casts = [
// Existing casts
'twitter_token' => 'object',
];
You can publish the config file with:
php artisan vendor:publish --tag="autotweet-for-laravel-config"
Update your Notification file's via
method to include the Twitter channel:
public function via(object $notifiable): array
{
return [TwitterChannel::class];
}
Add a toTwitter
method to your Notification file:
public function toTwitter($notifiable): TwitterMessage
{
$post = (new TwitterStatusUpdate(
__('Come see visit profile :url ❤️', ['url' => 'https://google.com/'])
));
// Optional: Add an image to the tweet
$post->withImage('path/to/image.jpg');
return $post;
}
To change the default user model, update the table used in the migration file and add the following code to your service provider:
AutotweetForLaravelServiceProvider::useUserModel(ExampleModel::class);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
Initially based on Laravel Twitter Channel
The MIT License (MIT). Please see License File for more information.