Sha256: 23189a429289aaa1d8b4e18c0d9e388a1c252a914120f1b72ec2f78a9ce83a1e

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

# encoding: utf-8
module MpWeixin
  module Interface

    # 发送消息
    class Message < Base
      # 发送客服消息
      # 文本消息:
      #
      # {
      #    "touser":"OPENID",
      #    "msgtype":"text",
      #    "text":
      #    {
      #         "content":"Hello World"
      #    }
      # }
      #
      # 发送图片消息:
      # {
      #    "touser":"OPENID",
      #    "msgtype":"image",
      #    "image":
      #    {
      #      "media_id":"MEDIA_ID"
      #    }
      # }
      # etc
      # @see http://mp.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E5%AE%A2%E6%9C%8D%E6%B6%88%E6%81%AF
      def custom_send(opts = nil)
        # JSON.generate(user_message.protocol_params, :ascii_only => true)
        opts_json = JSON.generate(opts, :ascii_only => false) if opts.is_a?(Hash)

        post '/cgi-bin/message/custom/send', :body => opts_json, :params => default_request_params
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mp_weixin-0.1.0 lib/mp_weixin/interface/message.rb