我一直在curl -XPOST
通过 bot api/key 发布一些到 Telegram 频道的链接,url 的形式为https://site/x/pre_encoded_string
,其中 的pre_encoded_string
形式为(真实样本)XOsmY90GWWA
, 4QHTV_K_WwQ
,它们是从 perl 的MIME::Base64
encode_base64url
函数生成的。
当生成的字符串包含下划线字符_
(如上面的第二个示例中所示)时,此操作会失败,下划线字符会被删除,并且curl
似乎会发布4QHTVKWwQ
即使我去掉--data-*
(binary,raw,urlencode) 并在 url 中传递字符串,它也会被删除。
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 ~ #
有什么线索可以告诉我我的问题出在哪里吗?