如何用setwebhook电报机器人解决我的问题

时间:2017-08-02 21:45:08

标签: php bots webhooks telegram

最近我遇到了电报机器人的setwebhook问题 我这样做了:

openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"

和此:

curl https://api.telegram.org/botxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/setWebhook \
-F "url=https://www.mywebsite.in.nf/test/bot1.php" \
-F "certificate=@/home/myUSER/YOURPUBLIC.pem"

我自己的php文件是:

$token = "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$json = file_get_contents("php://input");
$telegram = urldecode ($json);
$results = json_decode($telegram);
$message = $results->message;
$text = $message->text;
$chat = $message->chat;
$user_id = $chat->id;
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage?chat_id='.$user_id.'&text='.$text;
file_get_contents($url);

当我向bot发送消息时,它什么也没做。我无法找到错误,任何人都有类似的问题?

0 个答案:

没有答案