上传自签名 ssl 证书到电报 [英] Upload self-signed ssl certificate to telegram

查看:70
本文介绍了上传自签名 ssl 证书到电报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 php 上使用 webhook 制作电报机器人.问题是 webhook 设置不正确,idk 是怎么回事.我的 setwebhook 代码:

I'm making telegram bot using webhook on php. The problem is that the webhook doesn't set correctly and idk whats the matter. my setwebhook code :

$ch = curl_init(API_URL);
try {
    $cert = new \CURLFile(SSL_KEY);
apiRequest('setWebhook', array('url' =>  WEBHOOK_URL , 'certificate' => $cert));
    echo "webhook set";
} catch (Exception $e) {
    echo "error";
}

推荐答案

您可以通过终端而不是在您的代码中设置 webhook,如下所示:

You can set the webhook via the terminal rather than in your code like so:

curl -F "url=https://your_domain.com/where-the-script-will-be/bot-script.php" -F "certificate=@/location/of/cert/certificate.crt" https://api.telegram.org/bot000000000:AAAAa0aAA_aaA-Aaaa0A0Aa_a0aa0A0AAAA/setWebhook

这对我自己的项目有效,没有任何问题

This has worked for my own projects without any issues

这篇关于上传自签名 ssl 证书到电报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆