Module: Wechat::ShakeAround::Material
Instance Method Summary collapse
Instance Method Details
#upload(access_token, media, type) ⇒ Object
上传图片素材mp.weixin.qq.com/wiki/5/e997428269ff189d8f9a4b9e177be2d9.html
Return hash format if success: {
data: { pic_url: <ICON_LINK> },
errcode: 0,
errmsg: 'success.'
}
media 图片完整路径。type 是icon或者license。
17 18 19 20 21 22 23 24 |
# File 'lib/wechat/shake_around/material.rb', line 17 def upload(access_token, media, type) = nil File.open(media) do |io| = ::HTTPClient.new.post "https://api.weixin.qq.com/shakearound/material/add?access_token=#{access_token}&type=#{type}", { media: io } end body = .try :body body.present? ? JSON.parse(body) : nil end |