seven 5 zile în urmă
părinte
comite
1474594abc
1 a modificat fișierele cu 12 adăugiri și 0 ștergeri
  1. 12 0
      app/Http/Controllers/api/TelegramWebHook.php

+ 12 - 0
app/Http/Controllers/api/TelegramWebHook.php

@@ -22,6 +22,7 @@ use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use Telegram\Bot\Api;
 use Telegram\Bot\Exceptions\TelegramSDKException;
+use Illuminate\Support\Facades\Log;
 
 class TelegramWebHook extends Controller
 {
@@ -37,6 +38,17 @@ class TelegramWebHook extends Controller
         }
         $update = $telegram->getWebhookUpdate(); // 获取更新数据
         $update->callbackQuery;
+        Log::info('Telegram 回调数据(JSON): ' . json_encode($update, JSON_UNESCAPED_UNICODE));
+        return response()->json(['status' => 'ok']);
+    }
+
+
+    public function handleMessage()
+    {
+
+        $telegram = new Api(config('services.telegram.token'));
+        $update = $telegram->getWebhookUpdate(); // 获取更新数据
+        $update->callbackQuery;
         if ($update->has('callback_query')) {
 
             $json['type'] = 'callback_query';