Skip to content

weixin result handler

lanrion edited this page Apr 11, 2014 · 3 revisions

此页wiki,适用于 1.5.7以上的版本。

所有从微信返回的结果(json),此gem都会实例化成 ResultHandler,见:

https://github.com/lanrion/weixin_authorize/blob/master/lib/weixin_authorize/handler/result_handler.rb

举个例子说明此用法:

user_info_handler = $client.user(ENV["OPENID"])

puts user_info_handler.en_msg # 打印出英文提示信息
puts user_info_handler.cn_msg # 打印出中文提示信息

if user_info_handler.is_ok? # 或者 ok?
  user_info = user_info_handler.result # 这个方法直接返回微信的的json结果
 # do your work
else
  # 输出错误信息, 具体格式: "#{code}: #{en_msg}(#{cn_msg})."
  puts user_info.full_error_messages # 或者 errors 
end

Clone this wiki locally