Eu tenho usado curl -XPOST
para postar alguns links para um canal Telegram através de uma bot api / key, os urls estão no formato https://site/x/pre_encoded_string
, onde pre_encoded_string
está em forma (amostras reais) XOsmY90GWWA
, 4QHTV_K_WwQ
e são gerados a partir da função MIME::Base64
encode_base64url
do perl.
Isso falha quando a string gerada contém o caractere sublinhado _
(como na segunda amostra acima), que é removido, e curl
parece postar 4QHTVKWwQ
Mesmo se eu me livrar de --data-*
(binário, raw, urlencode) e passar a string na url, ela também será removida.
ais@rex ~ # curl -vv -s -XPOST 'https://api.telegram.org/bot1[...]4:AAE[...]Ggd3g/sendMessage?parse_mode=Markdown&chat_id=@xt2RM' --data-urlencode 'text=https://xt2/x/4QHTV_K_WwQ'
* Trying 149.154.167.198...
* Connected to api.telegram.org (149.154.167.198) port 443 (#0)
* Initializing NSS with certpath: none
* CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none
* NPN, server accepted to use http/1.1
* SSL connection using TLS_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* subject: CN=api.telegram.org,OU=Domain Control Validated
* start date: May 23 16:17:38 2015 GMT
* expire date: May 23 16:17:38 2018 GMT
* common name: api.telegram.org
* issuer: CN=Go Daddy Secure Certificate Authority - G2,OU=http://certs.godaddy.com/repository/,O="GoDaddy.com, Inc.",L=Scottsdale,ST=Arizona,C=US
> POST /bot1[...]4:A[...]ApJyf9Pg0/sendMessage?parse_mode=Markdown&chat_id=@xt2RM HTTP/1.1
> Host: api.telegram.org
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 55
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 55 out of 55 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.9.1
< Date: Mon, 28 Dec 2015 18:55:30 GMT
< Content-Type: application/json
< Content-Length: 193
< Connection: keep-alive
< Strict-Transport-Security: max-age=31536000; includeSubdomains
<
* Connection #0 to host api.telegram.org left intact
{"ok":true,"result":{"message_id":1506,"chat":{"id":-1[........]8,"title":"tty2RM","username":"tty2RM","type":"channel"},"date":1451328930,"text":"https:\/\/xt2\/x\/4QHTVKWwQ"}}
ais@rex ~ #
Alguma pista de como é o meu problema?
Tags curl base64 character-encoding