电报发送API使用PHP或javascript消息

电报发送API使用PHP或javascript消息

本文介绍了电报发送API使用PHP或javascript消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过它们的数量向用户发送消息?我看到这个网站,但目前还没有办法删除其引用中的消息。

How can I send messages to users via their number? I saw this site http://notificatio.divshot.io/ , but there is no way to delete its references in the messages.

推荐答案

您可以使用,这是一个易于使用的HTTP接口电报服务。用自己的来创建一个机器人令牌。 JavaScript的(的NodeJS)用法示例:

You can make use of the Telegram Bot API, it is an easy to use HTTP interface to the Telegram service. Use their BotFather to create a bot token. JavaScript (NodeJS) usage example:

var TelegramBot = require('telegrambot');
var api = new TelegramBot('<YOUR TOKEN HERE>');

// You can either use getUpdates or setWebHook to retrieve updates.
// getUpdates needs to be done on an interval and will contain all the
// latest messages send to your bot.

// Update the offset to the last receive update_id + 1
api.invoke('getUpdates', { offset: 0 }, function (err, updates) {
    if (err) throw err;
    console.log(updates);
});

// The chat_id received in the message update
api.invoke('sendMessage', { chat_id: <chat_id>, text: 'my message' }, function (err, message) {
    if (err) throw err;
    console.log(message);
});

此示例使用一个我用我的项目。

为了启动与用户的对话,你可以使用深层链接功能。例如,你可以把一个链接在您的网站,像这样:

In order to start a conversation with a user, you can use the deep-linking feature. For example, you can put a link on your website like so:

(有效载荷是一个自定义变量值,如果你想使用一个,像一个认证ID等)

https://telegram.me/triviabot?start=payload (payload being a custom variable value if you want to use one, like an auth ID etc)

下面这个链接会提示用户启动应用程序的电报,并添加到机器人的联系人列表。然后,您将收到通过getUpdates消息()与chat_id该用户打电话。这chat_id然后你可以用它来消息,任何你想要的用户。我不相信这是可能将消息发送给使用电报博特API一个手机号码,他们只用chat_id的工作,因为这是为了保护电报用户通过营销机器人被垃圾邮件的机制...这是你需要什么启动与机器人的第一次谈话。

Following that link will prompt the user to launch the Telegram App and add bot into the contact list. You will then receive a message via the getUpdates() call with the chat_id for that user. This chat_id you can then use to message the user whatever you want. I don't believe it's possible to send a message to a mobile number using the Telegram Bot API, they only work with chat_id's as this is a mechanism to protect Telegram users from being spammed by marketing bots...that is what you need to initiate the conversation with the bot first.

这篇关于电报发送API使用PHP或javascript消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:32