I have a PHP website where I keep a database of bot IDs and their corresponding tokens. I’m curious if there’s a way to confirm whether a Telegram bot is real or fake based on its ID and token.
Previously, I attempted to verify the bot’s existence by accessing its profile page through a specific URL format, but I didn’t get the expected results. Instead, I encountered issues where non-existing bots didn’t return proper error messages.
Can anyone advise on a reliable approach to verify whether a bot is authentic? Perhaps by using the Telegram API or other methods? I’d appreciate any insights as I’m looking to tidy up my database by removing non-valid bots.
Using the getMe API call is an effective method for verifying the authenticity of a Telegram bot. By sending a request to https://api.telegram.org/bot{token}/getMe, you will receive immediate feedback on the validity of the token. A valid bot will return details like its ID and username, while invalid tokens will produce 401 or 404 errors, allowing you to manage your database more efficiently. It’s essential to process the HTTP response codes adequately in your PHP code instead of relying solely on the response body, which can be inconsistent when scraping.
i usually go for file_get_contents() for the telegram api. if u get valid json with bot details, then its legit. otherwise, you’ll see an error response. super simple and works well for basic checks, no need for curl.
Had the same issue cleaning up my bot database last year. You need proper error handling with cURL in PHP for API requests. Don’t just check response content - verify the HTTP status code from Telegram’s API. Real bots with valid credentials return 200 plus bot info. Fake or invalid bots usually give you 401 Unauthorized or 403 Forbidden. I wrap the API call in try-catch and check both curl_getinfo($ch, CURLINFO_HTTP_CODE) and response structure. Works great for spotting invalid entries. Cleaned out about 30% of dead entries with zero false positives.