创建一个kik聊天机器人

时间:2016-10-23 07:56:32

标签: java python kik

我正在尝试用Python创建一个Kik bot

我是Python和REST的famailiar。我已经阅读了文档:

Kik Docs

首先,我需要:

requests.post(
'https://api.kik.com/v1/config',
auth=('<username>', '<api_key>'),
headers={
    'Content-Type': 'application/json'
},
data=json.dumps({
    'webhook': 'https://example.com/incoming', 
    'features': {
        'receiveReadReceipts': False, 
        'receiveIsTyping': False, 
        'manuallySendReadReceipts': False, 
        'receiveDeliveryReceipts': False
    }
})
)

但他们没有告诉我们什么&#34; webhook,&#34;或者这些代码真的意味着什么?

如何设置配置? 我应该为&#39;用户名&#39 ;?添加什么?我自己的用户名?

2 个答案:

答案 0 :(得分:1)

webhook是本地/生产服务器上将从Kik平台接收消息的路线

答案 1 :(得分:0)

API KEY:设置机器人后从dev.kik.com收到的密钥。 USERNAME:Bots用户名 URL:为服务器创建的URL。

第1步:下载NPM 第2步:在你的代码所在的文件中的CMD提示符中运行“npm install”(我使用C:\ Owners,虽然很确定它可以在任何地方) 第3步:下载NGROK(在命令提示符下运行“npm install ngrok -g”) 第4步:在CMD提示符中运行“ngrok http 8080” 第5步:打开index.js文件(可能是config / index.js) 第6步:输入你从ngrok获得的api密钥,用户名和链接,它应该是这样的。

Session Status                online
Version                       2.1.18
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://*********.ngrok.io -> localhost:8080
Forwarding                    https://*********.ngrok.io -> localhost:8080

Connections                   ttl     opn     rt1     rt5     p50     p90
                              128     0       0.00    0.00    95.46   120.78

***是将与您填写的数字。所以你举个例子

requests.post(
'https://api.kik.com/v1/config',
auth=('<botName>', '<1111-1111-1111-1111-1111>'),
    headers={
    'Content-Type': 'application/json'
    },
data=json.dumps({
    'webhook': 'http://111111111.ngrok.io', 
    'features': {
        'receiveReadReceipts': False, 
        'receiveIsTyping': False, 
        'manuallySendReadReceipts': False, 
        'receiveDeliveryReceipts': False
    }
})
)

在此之后,只要计算机没有关闭或命令窗口关闭,你就应该没问题。如果发生这种情况,请再次运行ngrok http 8080并将index.js中的链接替换为更新的链接。然后,有一些方法,如将域链接设置为服务器,因此您不需要保持服务器命令窗口打开,但我还没有尝试这个。如果我试过这个,我会尝试更新:)

-root