"\n"
and "\r\n"
, tested in text message sent by telegram bot, to create line break. Instead of showing line break, underline _
will appear after using them.
How I could printing line feed in telegram message sent by bot?
CODE
$txt = 'با تشکر از عضویت شما، هر روز حدود ساعت 10 شب یک ویدئوی جالب برای شما ارسال خواهد شد.';
$txt .= " \n ";
$txt .= 'Thanks for joining, Every day at almost 18:30 GMT an intersting video will be sent';
Any help will be appreciated.
All these answers are at the same time "right" and "wrong". In fact in depend a lot of the input you have. For example if you have a text area for input and then send the content to Telegram, if the user write in the text area and press return, the text in Telegram will be
and not
Performing URL encode will change nothing. After struggling a lot I discover a conflict with the fact sending the text area data from a page to another page escape some data.
The way I solve that is to remplace the escaped \n by a non-escaped one. So:
It works on Mac, PC and so on with text from text area.
For future visitor just I quote @Dagon answer in comments:
Using
%0A
will make line feed in telegram messagesyou should use urlencode to solve this problem:
it may be not show result as you wants in Unicode languages like Persian! you can prepare your text and use this:
There is a better way! The problem is because of URL encodings... You can use normal PHP text using
\n
but by passing it tourlencode
method, as follows:It works for me!
I solved the problem in this way :
try here : https://telegram-bot-sdk.readme.io/docs/sendmessage