'How can send a url to telegram bot?

I write a code to send a proxy link to my telegram bot but when i send the request my proxy link don't send complete

this is my code

#/bin/bash

TOKEN="***********************"
ID="************"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
PRLINK="tg://proxy?server=xxx.xxx.xxx.xxx&port=443&secret=eeb000000000000000000000000000"

curl -s -X POST $URL -d chat_id=$ID -d text=${PRLINK} > /root/sendResult

and this response

{ [..] ,"text":"tg://proxy?server=18.202.178.109", [..]}

in response

"text":"tg://proxy?server=18.202.178.109" no equal to PRLINK that me send with curl



Solution 1:[1]

The problem is related to URL encoding: https://www.w3schools.com/tags/ref_urlencode.ASP

In a nutshell, you should encode the ampersand character in order to let the entire URL be considered properly.

So that, the ampersand character is encoded as %26, therefore:

Your code should be:

#/bin/bash

TOKEN="***********************"
ID="************"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
PRLINK="tg://proxy?server=xxx.xxx.xxx.xxx%26port=443%26secret=eeb000000000000000000000000000"

curl -s -X POST $URL -d chat_id=$ID -d text=${PRLINK} > /root/sendResult

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Istorn