Module: WechatPublicApi::Material
- Included in:
- WechatPublicApi
- Defined in:
- lib/wechat_public_api/material.rb
Instance Method Summary collapse
-
#upload_image_material(file_path) ⇒ json
新增永久图片素材 if false.
-
#upload_image_media(file_path) ⇒ json
获得临时图片素材的 media_id if false.
Instance Method Details
#upload_image_material(file_path) ⇒ json
新增永久图片素材 if false
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wechat_public_api/material.rb', line 37 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 |
#upload_image_media(file_path) ⇒ json
获得临时图片素材的 media_id if false
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wechat_public_api/material.rb', line 18 def upload_image_media(file_path) # request access_token access_token = get_access_token() response = RestClient.post('https://api.weixin.qq.com/cgi-bin/media/upload', { access_token: access_token, type: 'image', media: File.new(file_path, 'rb')}) JSON.parse(response) end |