getApiUrl()}\n\n"; // 2. Create HTTP client and Telegram client echo "2ļøāƒ£ Creating Telegram client...\n"; $httpClient = new CurlHttpClient(); $telegramClient = new TelegramClient($httpClient, $config); echo " āœ… Client created\n\n"; // 3. Test bot info echo "3ļøāƒ£ Testing bot connection (getMe)...\n"; try { $botInfo = $telegramClient->getMe(); echo " āœ… Bot connected successfully!\n"; echo " šŸ¤– Bot Name: {$botInfo['first_name']}\n"; echo " šŸ“› Username: @{$botInfo['username']}\n"; echo " šŸ†” Bot ID: {$botInfo['id']}\n\n"; } catch (\Throwable $e) { echo " āŒ Bot connection failed: {$e->getMessage()}\n\n"; } // 4. Test chat ID $testChatId = TelegramChatId::fromString('8240973979'); echo "4ļøāƒ£ Test recipient: {$testChatId->toString()}\n\n"; // 5. Send text message echo "5ļøāƒ£ Sending text message...\n"; try { $response = $telegramClient->sendMessage( chatId: $testChatId, text: "šŸŽ‰ Test message from Custom PHP Framework!\n\nThis is a test notification via Telegram Bot API.", parseMode: 'Markdown' ); echo " āœ… Message sent successfully!\n"; echo " šŸ“Ø Message ID: {$response->messageId->toString()}\n\n"; } catch (\Throwable $e) { echo " āŒ Text message failed: {$e->getMessage()}\n\n"; } // 6. Send formatted message echo "6ļøāƒ£ Sending formatted message with Markdown...\n"; try { $formattedText = "*Bold Title*\n\n" . "_Italic text_\n\n" . "`Code block`\n\n" . "[Click here](https://example.com)"; $response = $telegramClient->sendMessage( chatId: $testChatId, text: $formattedText, parseMode: 'Markdown' ); echo " āœ… Formatted message sent!\n"; echo " šŸ“Ø Message ID: {$response->messageId->toString()}\n\n"; } catch (\Throwable $e) { echo " ā„¹ļø Formatted message skipped: {$e->getMessage()}\n\n"; } echo "āœ… Telegram notification test completed!\n\n"; echo "šŸ“ Notes:\n"; echo " - Create a bot via @BotFather on Telegram\n"; echo " - Get your chat ID by messaging the bot and checking /getUpdates\n"; echo " - Replace YOUR_BOT_TOKEN_HERE with actual bot token\n"; echo " - Replace YOUR_CHAT_ID_HERE with your actual chat ID\n"; echo " - Bot token format: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz\n"; } catch (\Throwable $e) { echo "\nāŒ Test failed: {$e->getMessage()}\n"; echo "Stack trace:\n{$e->getTraceAsString()}\n"; exit(1); }