Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

spatie/freek.dev

636 stars
2 code files
View spatie/freek.dev on GitHub

app/Services/Twitter/TwitterServiceProvider.php

Open in GitHub
use Abraham\TwitterOAuth\TwitterOAuth;
use Illuminate\Support\ServiceProvider;
 
class TwitterServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(Twitter::class, function () {
$connection = new TwitterOAuth(
config('services.twitter.consumer_key'),
config('services.twitter.consumer_secret'),
config('services.twitter.access_token'),
config('services.twitter.access_token_secret')
);
 
return new Twitter($connection);
});
}
}

app/Services/Twitter/Twitter.php

Open in GitHub
use Abraham\TwitterOAuth\TwitterOAuth;
 
class Twitter
{
protected TwitterOAuth $twitter;
 
public function __construct(TwitterOAuth $twitter)
{
$this->twitter = $twitter;
}
 
public function tweet(string $status)
{
if (! app()->environment('production')) {
return;
}
 
return (array)$this->twitter->post('statuses/update', compact('status'));
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.