I use this: https://telegram-bot-sdk.readme.io/docs
$response = $telegram->sendMessage([
'chat_id' => '@username',
'text' => 'Hello World'
]);
when the username is true, it works. but how can I handle errors? for example when username is wrong or not exist.
1-Some people does not have username!(you can have telegram account with just first name and valid phone number)
2-You cannot send to any valid username(Your bot can just send to users subscribed to your bot (open a chat at least once) and not blocked afterwards)
3-By telegram you can just send to users by
chat_id
( a large unique number) and not by@username
.