Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

material 永久素材命令调用接口变了? #275

Closed
0000sir opened this issue Mar 4, 2020 · 2 comments
Closed

material 永久素材命令调用接口变了? #275

0000sir opened this issue Mar 4, 2020 · 2 comments
Assignees

Comments

@0000sir
Copy link

0000sir commented Mar 4, 2020

用Wechat.api.material media_id(永久素材列表获取的media_id)获取媒体文件时总是提示40007,翻代码翻到 common.rb 中

def material(media_id)
        get 'material/get', params: { media_id: media_id }, as: :file
end

推测调用的url是 material/get,微信文档中 material/get_material 是获取永久素材的接口,且调用方式是post(文档地址 https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Getting_Permanent_Assets.html)

微信改接口了?

@0000sir 0000sir changed the title material 永久素材命令实际调用的是临时素材接口? material 永久素材命令调用接口变了? Mar 4, 2020
@0000sir
Copy link
Author

0000sir commented Mar 4, 2020

直接改成 post 'material/get_material' 会报以下 cannot determine size of body 错误

HTTP::RequestError: cannot determine size of body: {:params=>{:media_id=>"nONZrMG8hS8nglm-8PuJBe7AD_0sUBmKdyWFm7P0Eds"}, :as=>:file}

不知道能如何处理,拼凑curl命令能够勉强使用:

token = Wechat.api.access_token.token
        output = Tempfile.new
        cmd = "curl \"https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=#{token}\" -d '{\"media_id\":\"#{media_id}\"}' > #{output.path}"
        p output.path
        system(cmd)

@Eric-Guo Eric-Guo self-assigned this Mar 5, 2020
@Eric-Guo
Copy link
Owner

Eric-Guo commented Mar 9, 2020

确实变了,已发新版本0.11.8修正。

@Eric-Guo Eric-Guo closed this as completed Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants