Module: WeixinAuthorize::Api::Custom
- Included in:
- Client
- Defined in:
- lib/weixin_authorize/api/custom.rb
Instance Method Summary collapse
-
#send_image_custom(to_user, media_id) ⇒ Object
发送图片消息 { “touser”:“OPENID”, “msgtype”:“image”, “image”: { “media_id”:“MEDIA_ID” } }.
-
#send_music_custom(to_user, media_id, musicurl, hqmusicurl, options = {}) ⇒ Object
发送音乐消息 { “touser”:“OPENID”, “msgtype”:“music”, “music”: { “title”:“MUSIC_TITLE”, “description”:“MUSIC_DESCRIPTION”, “musicurl”:“MUSIC_URL”, “hqmusicurl”:“HQ_MUSIC_URL”, “thumb_media_id”:“THUMB_MEDIA_ID” } }.
-
#send_news_custom(to_user, articles = []) ⇒ Object
发送图文消息 { “touser”:“OPENID”, “msgtype”:“news”, “news”:{ “articles”: [ { “title”:“Happy Day”, “description”:“Is Really A Happy Day”, “url”:“URL”, “picurl”:“PIC_URL” }, { “title”:“Happy Day”, “description”:“Is Really A Happy Day”, “url”:“URL”, “picurl”:“PIC_URL” } ] } }.
-
#send_text_custom(to_user, content) ⇒ Object
发送文本消息 { “touser”:“OPENID”, “msgtype”:“text”, “text”: { “content”:“Hello World” } }.
-
#send_video_custom(to_user, media_id, options = {}) ⇒ Object
发送视频消息 { “touser”:“OPENID”, “msgtype”:“video”, “video”: { “media_id”:“MEDIA_ID” } }.
-
#send_voice_custom(to_user, media_id) ⇒ Object
发送语音消息 { “touser”:“OPENID”, “msgtype”:“voice”, “voice”: { “media_id”:“MEDIA_ID” } }.
Instance Method Details
#send_image_custom(to_user, media_id) ⇒ Object
发送图片消息{
"touser":"OPENID",
"msgtype":"image",
"image":
{
"media_id":"MEDIA_ID"
}
}
29 30 31 32 |
# File 'lib/weixin_authorize/api/custom.rb', line 29 def send_image_custom(to_user, media_id) = (to_user, "image").merge({image: {media_id: media_id}}) http_post(custom_base_url, ) end |
#send_music_custom(to_user, media_id, musicurl, hqmusicurl, options = {}) ⇒ Object
发送音乐消息{
"touser":"OPENID",
"msgtype":"music",
"music":
{
"title":"MUSIC_TITLE",
"description":"MUSIC_DESCRIPTION",
"musicurl":"MUSIC_URL",
"hqmusicurl":"HQ_MUSIC_URL",
"thumb_media_id":"THUMB_MEDIA_ID"
}
}
76 77 78 79 80 81 82 83 |
# File 'lib/weixin_authorize/api/custom.rb', line 76 def send_music_custom(to_user, media_id, musicurl, hqmusicurl, ={}) = { thumb_media_id: media_id, musicurl: musicurl, hqmusicurl: hqmusicurl }.merge() = (to_user, "music").merge({music: }) http_post(custom_base_url, ) end |
#send_news_custom(to_user, articles = []) ⇒ Object
发送图文消息{
"touser":"OPENID",
"msgtype":"news",
"news":{
"articles": [
{
"title":"Happy Day",
"description":"Is Really A Happy Day",
"url":"URL",
"picurl":"PIC_URL"
},
{
"title":"Happy Day",
"description":"Is Really A Happy Day",
"url":"URL",
"picurl":"PIC_URL"
}
]
}
}
106 107 108 109 |
# File 'lib/weixin_authorize/api/custom.rb', line 106 def send_news_custom(to_user, articles=[]) = (to_user, "news").merge({news: {articles: articles}}) http_post(custom_base_url, ) end |
#send_text_custom(to_user, content) ⇒ Object
发送文本消息{
"touser":"OPENID",
"msgtype":"text",
"text":
{
"content":"Hello World"
}
}
15 16 17 18 |
# File 'lib/weixin_authorize/api/custom.rb', line 15 def send_text_custom(to_user, content) = (to_user).merge({text: {content: content}}) http_post(custom_base_url, ) end |
#send_video_custom(to_user, media_id, options = {}) ⇒ Object
发送视频消息{
"touser":"OPENID",
"msgtype":"video",
"video":
{
"media_id":"MEDIA_ID"
}
}
57 58 59 60 61 |
# File 'lib/weixin_authorize/api/custom.rb', line 57 def send_video_custom(to_user, media_id, ={}) = {media_id: media_id}.merge() = (to_user, "video").merge({video: }) http_post(custom_base_url, ) end |
#send_voice_custom(to_user, media_id) ⇒ Object
发送语音消息{
"touser":"OPENID",
"msgtype":"voice",
"voice":
{
"media_id":"MEDIA_ID"
}
}
43 44 45 46 |
# File 'lib/weixin_authorize/api/custom.rb', line 43 def send_voice_custom(to_user, media_id) = (to_user, "voice").merge({voice: {media_id: media_id}}) http_post(custom_base_url, ) end |