Telegram

1
Класс для отправки сообщений в telegram через бота
app/Utilities/TelegramMessage.php
                            
<?php
 
namespace App\Utilities;
 
use Illuminate\Support\Facades\Http;
 
class TelegramMessage
{
public static function send(string $text, string $chatId = null)
{
return Http::post(
sprintf('https://api.telegram.org/bot%s/sendMessage', config('services.telegram.bot_token')),
[
'chat_id' => $chatId ? $chatId : config('services.telegram.chat_id'),
'text' => $text,
]
);
}
}
config/services.php
                            
<?php
 
return [
 
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
 
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
 
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
 
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
 
'telegram' => [
'bot_token' => env('TELEGRAM_BOT_TOKEN'),
'chat_id' => '-1111111111111',
],
];