return $result;
}
+ public static function sendPromo2MessageToTelegramDocument($chatId)
+ {
+ if (self::isDevEnv()) {
+ $botToken = self::TELEGRAM_BOT_DEV;
+ } else {
+ $botToken = self::TELEGRAM_BOT_PROD;
+ }
+ $apiURL1 = "https://api.telegram.org/bot{$botToken}/sendMediaGroup";
+ $apiURL2 = "https://api.telegram.org/bot{$botToken}/sendMessage";
+
+ $text = 'АКЦИЯ: –20% НА БУКЕТЫ ДНЯ — с 4 по 11 июля 🔥
+
+Только 7 дней: Скидка 20% на три стильных букета из нашей летней коллекции!';
+
+ $pic1Path = curl_file_create(
+ __DIR__ . '/../web/images/pic_1.jpg',
+ 'image/jpg',
+ 'pic_1.jpg'
+ );
+
+ $pic2Path = curl_file_create(
+ __DIR__ . '/../web/images/pic_2.jpg',
+ 'image/jpg',
+ 'pic_2.jpg'
+ );
+
+ $pic3Path = curl_file_create(
+ __DIR__ . '/../web/images/pic_3.jpg',
+ 'image/jpg',
+ 'pic_3.jpg'
+ );
+
+ $result = 'false';
+
+ if (!empty($chatId)) {
+ try {
+ $buttons = self::getTgShortButtons($chatId);
+
+ $client = new Client();
+ try {
+ $response1 = $client->post($apiURL1, [
+ 'json' => [
+ 'chat_id' => $chatId,
+ 'media' => json_encode([
+ ['type' => 'photo', 'media' => 'attach://pic_1.jpg', "caption" => $text],
+ ['type' => 'photo', 'media' => 'attach://pic_2.jpg' ],
+ ['type' => 'photo', 'media' => 'attach://pic_3.jpg' ],
+ ]),
+ 'pic_1.jpg' => $pic1Path,
+ 'pic_2.jpg' => $pic2Path,
+ 'pic_3.jpg' => $pic3Path,
+ ],
+ ]);
+
+ if ($response1->getStatusCode() !== 200) {
+ Yii::error("Ошибка при отправке сообщения в Telegram. Код ответа: "
+ . $response1->getStatusCode(), 'telegram');
+ return $response1->getStatusCode();
+ }
+ } catch (\Exception $e) {
+ Yii::error("Ошибка отправки сообщения в Telegram: " . $e->getMessage(), 'telegram');
+ return $e->getMessage();
+ }
+
+ try {
+ $response = $client->post($apiURL2, [
+ 'json' => [
+ 'chat_id' => $chatId,
+ "text" => "Выберите действие:",
+ 'parse_mode' => 'MarkdownV2',
+ 'reply_markup' => Json::encode([
+ "inline_keyboard" => $buttons
+ ]),
+ ],
+ ]);
+
+ if ($response->getStatusCode() !== 200) {
+ Yii::error("Ошибка при отправке сообщения в Telegram. Код ответа: "
+ . $response->getStatusCode(), 'telegram');
+ return $response->getStatusCode();
+ }
+
+ return $response->getReasonPhrase();
+ } catch (\Exception $e) {
+ Yii::error("Ошибка отправки сообщения в Telegram: " . $e->getMessage(), 'telegram');
+ return $e->getMessage();
+ }
+
+ } catch (\Exception $e) {
+
+ Yii::error("Ошибка отправки сообщения в Telegram: " . $e->getMessage(), 'telegram');
+ }
+ $result = 'OK';
+ }
+
+ return $result;
+ }
public static function sendMessageToTelegramClient($chatId, $message)
{