Source: stitcher.io

I'm a code folder
This is where the ad would go. If you're a regular reader and my content is helping you, you can consider a one-time or monthly sponsorship. If you're a company looking for dedicated ad placements on this blog or my newsletter, you can email me at mailto:brendt@stitcher.io

class TwitterSyncCommand extends Command { protected $signature = 'twitter:sync {--clean}'; private Collection $mutes; public function handle(Twitter $twitter) { } public function syncFromList(Twitter $twitter): void { } public function syncFromSearch(Twitter $twitter): void { } private function storeTweets(array $tweets, TweetFeedType $feedType): void { } private function shouldBeRejected(Tweet $tweet): ?RejectionReason { }}

class TwitterSyncCommand extends Command { protected $signature = 'twitter:sync {--clean}'; private Collection $mutes; public function handle(Twitter $twitter) { $this->mutes = Mute::query()->select('text')->get(); if ($this->option('clean')) { $this->error('Truncating tweets!'); Tweet::truncate(); } $this->syncFromSearch($twitter); $this->syncFromList($twitter); $this->info('Done'); } public function syncFromList(Twitter $twitter): void { do { $lastTweet = Tweet::query() ->where('feed_type', TweetFeedType::LIST) ->orderByDesc('tweet_id') ->first(); $tweets = $twitter->request('lists/statuses.json', 'GET', [ 'list_id' => config('services.twitter.list_id'), 'since_id' => $lastTweet?->tweet_id, 'count' => 200, 'tweet_mode' => 'extended', ]); $count = count($tweets); if ($count === 0) { $this->comment('No more new tweets'); } else { $this->comment("Syncing {$count} tweets from list"); $this->storeTweets($tweets, TweetFeedType::LIST); }} while ($tweets !== []); } public function syncFromSearch(Twitter $twitter): void { do { $lastTweet = Tweet::query() ->where('feed_type', TweetFeedType::SEARCH) ->orderByDesc('tweet_id') ->first(); $tweets = $twitter->request('/search/tweets.json', 'GET', [ 'q' => 'phpstorm', 'since_id' => $lastTweet?->tweet_id, 'count' => 200, 'tweet_mode' => 'extended', ])->statuses; $count = count($tweets); if ($count === 0) { $this->comment('No more new tweets'); } else { $this->comment("Syncing {$count} tweets from search"); $this->storeTweets($tweets, TweetFeedType::SEARCH); }} while ($tweets !== []); } private function storeTweets(array $tweets, TweetFeedType $feedType): void { foreach ($tweets as $tweet) { $subject = $tweet->retweeted_status ??
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners