A
A
alekse314192019-08-29 16:56:24
PHP
alekse31419, 2019-08-29 16:56:24

Telegram Api Bot sends applications from the site without a + sign in the phone field. How to fix?

There is a code:

$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=HTML&text={$txt}","r");

When a person on the site enters a phone number starting with a + sign, the number comes up without it. How to make sure that the plus also comes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2019-08-29
@alekse31419

Use urlencode() to encode the parameters passed in the GET string.
According to the standard, a space is encoded with a plus, the plus itself is transmitted as% 2B.

T
ThunderCat, 2019-08-29
@ThunderCat

$txt = str_replace('+','+',$txt);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question