Chatwork SDK for Laravel 5, 6, 7.
Using composer:
composer require sun-asterisk/laravel-chatwork
For Laravel 5.4 and earlier, add the service provider to your config/app.php
.
'providers' => [
// ...
SunAsterisk\Chatwork\Laravel\ServiceProvider::class
// ...
];
First register an API Key here.
Then add the API key to your .env
:
CHATWORK_API_KEY=your_api_key_here
You can use the provided facade via an alias:
use Chatwork;
$me = Chatwork::me();
$members = Chatwork::room($roomId)->members()->list();
Or use dependency injection:
use SunAsterisk\Chatwork\Chatwork;
class ChatworkCommand extends Command
{
public function handle(Chatwork $chatwork)
{
$message = $chatwork->toAll()->text('Hi there');
$chatwork->room($roomId)->messages()->create($message);
}
}