【问题标题】:Using kik's API with ruby将 kik 的 API 与 ruby​​ 一起使用
【发布时间】:2016-11-27 01:51:53
【问题描述】:

好吧,我正在学习 ruby​​,想为 kik https://dev.kik.com 创建一个机器人,我只是不明白出了什么问题。

这是代码

require 'HTTParty'
require 'base64'
require 'json'

bot_name = #bot_name
api_key = #api_key
message = Message.new(self)

HTTParty.post('https://api.kik.com/v1/config',
headers: {
  'Content-Type' => 'application/json',
  'Authorization' => "#{bot_name}:#{api_key}",
},
 body: {
   "manuallySendReadReceipts" => false,
   "receiveReadReceipts" => true,
   "receiveDeliveryReceipts" => true,
   "receiveIsTyping" => true,
   message: [
   {
    body: message,
    to: user_name,
    type: 'text',
    chatId: chat_id
   }
  ],
  debug_output: $stdout
 }
)

这是错误:

kikBot.rb:7:in `<main>': uninitialized constant Message (NameError)

大部分代码是通过引用 gem 创建的

有没有办法在本地测试它并让它打印出一些“连接成功”之类的东西。

【问题讨论】:

    标签: ruby rubygems http-authentication httparty kik


    【解决方案1】:

    错误消息说。 uninitialized constant Massage,而带有错误的行告诉我们模型名为 Message

    您的代码库中似乎有错字。在您的代码库中搜索 Massage 并将其替换为 Message

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多