Telegram 机器人发送二维码 php
Telegram bot send QR code php
我有电报机器人,我的机器人会发送带有二维码的欢迎消息。
用户id生成的二维码。现在我有这个代码......
$botToken = "";
$website = "https://api.telegram.org/bot".$botToken;
$content = file_get_contents("php://input");
$update = json_decode($content, TRUE);
$message = $update["message"];
$chatId = $message["chat"]["id"];
$text = $message["text"];
if ($text == '/start') {
$welcomemessage = 'Добро пожаловать. Сохраните полученный id и введите его в приложение I am here: ';
file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$welcomemessage);
file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$chatId); // send QR picture will be here
}
可能是http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=a&chld= (user_id)
sendPhoto至少需要两个参数;第一个是目标 chat_id,第二个是 photo 你有三个选择:
- 如果照片已经上传到电报服务器,则通过 file_id(推荐,因为您不需要重新上传)。
- 如果照片上传到其他地方,请传递完整的 http url,telegram 将下载它(最大照片大小为 5MB atm)。
Post 使用 multipart/form-data 的文件就像您想通过浏览器上传它一样(这种方式最大照片大小为 10MB)。
你可以试试这个:
$website."/sendPhoto?chat_id=".$chatId."&photo=".$yourPhotoURL
注意 docs :
When sending by URL the target file must have the correct MIME type (e.g., audio/mpeg for sendAudio, etc.).
我有电报机器人,我的机器人会发送带有二维码的欢迎消息。 用户id生成的二维码。现在我有这个代码......
$botToken = "";
$website = "https://api.telegram.org/bot".$botToken;
$content = file_get_contents("php://input");
$update = json_decode($content, TRUE);
$message = $update["message"];
$chatId = $message["chat"]["id"];
$text = $message["text"];
if ($text == '/start') {
$welcomemessage = 'Добро пожаловать. Сохраните полученный id и введите его в приложение I am here: ';
file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$welcomemessage);
file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$chatId); // send QR picture will be here
}
可能是http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=a&chld= (user_id)
sendPhoto至少需要两个参数;第一个是目标 chat_id,第二个是 photo 你有三个选择:
- 如果照片已经上传到电报服务器,则通过 file_id(推荐,因为您不需要重新上传)。
- 如果照片上传到其他地方,请传递完整的 http url,telegram 将下载它(最大照片大小为 5MB atm)。
Post 使用 multipart/form-data 的文件就像您想通过浏览器上传它一样(这种方式最大照片大小为 10MB)。
你可以试试这个:$website."/sendPhoto?chat_id=".$chatId."&photo=".$yourPhotoURL
注意 docs :
When sending by URL the target file must have the correct MIME type (e.g., audio/mpeg for sendAudio, etc.).