Class: MpWeixin::Interface::Menu
- Defined in:
- lib/mp_weixin/interface/menu.rb
Overview
自定义菜单
Instance Method Summary collapse
-
#create(opts = nil) ⇒ Object
自定义菜单创建接口:.
-
#delete(opts = {}) ⇒ Object
自定义菜单查询接口 http请求方式:GET api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN.
-
#get_menus(opts = {}) ⇒ Object
自定义菜单查询接口 http请求方式:GET api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN.
Methods inherited from Base
#default_request_params, #get, #initialize, #post, #request
Constructor Details
This class inherits a constructor from MpWeixin::Interface::Base
Instance Method Details
#create(opts = nil) ⇒ Object
自定义菜单创建接口:
一个公众账号,最多支持创建500个分组。 接口调用请求说明
{
"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"
}]
}]
}
46 47 48 49 50 51 |
# File 'lib/mp_weixin/interface/menu.rb', line 46 def create(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/menu/create', :body => opts_json, :params => default_request_params end |
#delete(opts = {}) ⇒ Object
自定义菜单查询接口 http请求方式:GET
https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN
65 66 67 |
# File 'lib/mp_weixin/interface/menu.rb', line 65 def delete(opts = {}) get '/cgi-bin/menu/delete', :params => opts.merge(default_request_params) end |
#get_menus(opts = {}) ⇒ Object
自定义菜单查询接口 http请求方式:GET
https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN
57 58 59 |
# File 'lib/mp_weixin/interface/menu.rb', line 57 def (opts = {}) get '/cgi-bin/menu/get', :params => opts.merge(default_request_params) end |