Module: EasyWeixin::Response

Extended by:
Response
Included in:
Message, Response
Defined in:
lib/easy_weixin/response.rb

Instance Method Summary collapse

Instance Method Details

#analysis_xml(request_xml) ⇒ Object



26
27
28
29
# File 'lib/easy_weixin/response.rb', line 26

def analysis_xml(request_xml)
  hash = MultiXml.parse(request_xml)['xml']
  source = OpenStruct.new(hash)
end

#news_msg(from, to, articles, articleCount = 1) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/easy_weixin/response.rb', line 14

def news_msg(from, to, articles, articleCount=1)
  msg = NewsReplyMessage.new
  msg.ToUserName   = to
  msg.FromUserName = from
  unless articles.is_a?(Array)
    articles = [articles]
  end
  msg.Articles = articles
  msg.ArticleCount = articleCount
  msg.to_xml
end

#text_msg(from, to, content) ⇒ Object

创建文本信息



6
7
8
9
10
11
12
# File 'lib/easy_weixin/response.rb', line 6

def text_msg(from, to, content)
  msg = TextReplyMessage.new
  msg.ToUserName   = to
  msg.FromUserName = from
  msg.Content = content
  msg.to_xml
end