module WeixinAuthorize::Api::Custom

def custom_base_url

https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
def custom_base_url
  "/message/custom/send"
end

def default_options(to_user, msgtype="text")

def default_options(to_user, msgtype="text")
  {touser: to_user, msgtype: msgtype}
end

def send_image_custom(to_user, media_id)

}
}
"media_id":"MEDIA_ID"
{
"image":
"msgtype":"image",
"touser":"OPENID",
{
发送图片消息
def send_image_custom(to_user, media_id)
  message = default_options(to_user, "image").merge({image: {media_id: media_id}})
  http_post(custom_base_url, message)
end

def send_music_custom(to_user, media_id, musicurl, hqmusicurl, options={})

}
}
"thumb_media_id":"THUMB_MEDIA_ID"
"hqmusicurl":"HQ_MUSIC_URL",
"musicurl":"MUSIC_URL",
"description":"MUSIC_DESCRIPTION",
"title":"MUSIC_TITLE",
{
"music":
"msgtype":"music",
"touser":"OPENID",
{
发送音乐消息
def send_music_custom(to_user, media_id, musicurl, hqmusicurl, options={})
  music_options = { thumb_media_id: media_id,
                    musicurl: musicurl,
                    hqmusicurl: hqmusicurl
                  }.merge(options)
  message = default_options(to_user, "music").merge({music: music_options})
  http_post(custom_base_url, message)
end

def send_news_custom(to_user, articles=[])

}
}
]
}
"picurl":"PIC_URL"
"url":"URL",
"description":"Is Really A Happy Day",
"title":"Happy Day",
{
},
"picurl":"PIC_URL"
"url":"URL",
"description":"Is Really A Happy Day",
"title":"Happy Day",
{
"articles": [
"news":{
"msgtype":"news",
"touser":"OPENID",
{
发送图文消息
def send_news_custom(to_user, articles=[])
  message = default_options(to_user, "news").merge({news: {articles: articles}})
  http_post(custom_base_url, message)
end

def send_text_custom(to_user, content)

}
}
"content":"Hello World"
{
"text":
"msgtype":"text",
"touser":"OPENID",
{
发送文本消息
def send_text_custom(to_user, content)
  message = default_options(to_user).merge({text: {content: content}})
  http_post(custom_base_url, message)
end

def send_video_custom(to_user, media_id, options={})

}
}
"media_id":"MEDIA_ID"
{
"video":
"msgtype":"video",
"touser":"OPENID",
{
发送视频消息
def send_video_custom(to_user, media_id, options={})
  video_options = {media_id: media_id}.merge(options)
  message = default_options(to_user, "video").merge({video: video_options})
  http_post(custom_base_url, message)
end

def send_voice_custom(to_user, media_id)

}
}
"media_id":"MEDIA_ID"
{
"voice":
"msgtype":"voice",
"touser":"OPENID",
{
发送语音消息
def send_voice_custom(to_user, media_id)
  message = default_options(to_user, "voice").merge({voice: {media_id: media_id}})
  http_post(custom_base_url, message)
end