V
V
VN2021-07-06 13:05:02
API
VN, 2021-07-06 13:05:02

Why isn't the full value of the variable passed through the Telegram API?

There is a variable When sending it via the Telegram API

RES=$(echo "my time is $(date +%F)")

curl -s "https://api.telegram.org/bot$API_KEY/sendMessage?chat_id=$CHAT_ID&text="$RES"" >/dev/null


In chat I get only the first word my . How to get the entire value of a variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-07-06
@kavabangaungava

Because spaces need to be replaced with %20

#!/bin/bash
API_KEY="some_key"
RES=$(echo "my time is $(date +%F)" | sed  "s/ /%20/g")
echo $RES
CHAT_ID=11111
curl -s "https://api.telegram.org/bot$API_KEY/sendMessage?chat_id=$CHAT_ID&text="$RES"" >/dev/null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question