Skip to main content

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

Read more here

christophrumpel/larastreamers

238 stars
3 code files
View christophrumpel/larastreamers on GitHub

app/Jobs/TweetStreamIsLiveJob.php

Open in GitHub
use App\Models\Stream;
use App\Services\Twitter;
 
class TweetStreamIsLiveJob
{
public function __construct(
public Stream $stream,
) {}
 
public function handle(): void
{
//
app(Twitter::class)
->tweet("? A new stream just started: {$this->stream->title}".PHP_EOL.$this->stream->url());
}
}

app/Services/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'));
}
}

composer.json

Open in GitHub
{
"require": {
"php": "^8.0",
"abraham/twitteroauth": "^2.0",
//
},
}

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.