Commit b97d7d00 by lanrion

refactor menu.rb

parent d2df2d80
......@@ -20,6 +20,7 @@ module WeixinAuthorize
# 自定义菜单创建接口
# https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
def create_menu(menu)
menu = MultiJson.load(menu) if menu.is_a?(String)
create_menu_url = "#{menu_base_url}/create"
http_post(create_menu_url, menu)
end
......
......@@ -5,10 +5,8 @@ describe WeixinAuthorize::Api::Menu do
it "can create a menu" do
menu = '{"button":[{"type":"click","name":"今日歌曲","key":"V1001_TODAY_MUSIC"},{"type":"click","name":"歌手简介","key":"V1001_TODAY_SINGER"},{"name":"菜单","sub_button":[{"type":"view","name":"搜索","url":"http://www.soso.com/"},{"type":"view","name":"视频","url":"http://v.qq.com/"},{"type":"click","name":"赞一下我们","key":"V1001_GOOD"}]}]}'
response = $client.create_menu(menu)
puts response
response = $client.create_menu(MultiJson.load(menu)) # or Json string
expect(response["errcode"]).to eq(0)
end
it "can get a weixin Menu info" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment