-
app/Services/Twitter/TwitterServiceProvider.php
Open in GitHubuse 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 GitHubuse 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')); } }