Sha256: 6228251df6f247e062a0750c01d9feb573806a7f009c0b7479ff1b18368cfd06
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
##################################################### # 微信公众号素材管理 # Created by zhangmingxin # Date: 2018-05-18 # Wechat number: zmx119966 #################################################### class WxApi module Material ### # 获得临时图片素材的 media_id # @param <string> file_path -- 图片素材的路径 # # @return <json> {"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789} # if false # @return <json> {"errcode":40004,"errmsg":"invalid media type"} # def upload_image_media(file_path) # request access_token access_token = get_access_token() response = RestClient.post("#{prefix}/cgi-bin/media/upload", { access_token: access_token, type: 'image', media: File.new(file_path, 'rb')}) JSON.parse(response) end ### # 新增永久图片素材 # @param <string> file_path -- 图片素材的路径 # # @return <json> {"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789} # if false # @return <json> {"errcode":40004,"errmsg":"invalid media type"} # def upload_image_material(file_path) # request access_token access_token = get_access_token() response = RestClient.post('https://api.weixin.qq.com/cgi-bin/material/add_material', { access_token: access_token, type: 'image', media: File.new(file_path, 'rb')}) JSON.parse(response) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wxapi-1.0.1 | lib/wxapi/material.rb |
wxapi-1.0.0 | lib/wxapi/material.rb |