1. Interface for taking pictures or selecting pictures from the mobile phone album
wx.chooseImage({
<code>count: 1, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 }</code>
});
2. Upload image interface
wx.uploadImage({
<code>localId: '', // 需要上传的图片的本地ID,由chooseImage接口获得 isShowProgressTips: 1, // 默认为1,显示进度提示 success: function (res) { var serverId = res.serverId; // 返回图片的服务器端ID }</code>
});
3. Download multimedia files
The public account can call this interface to obtain multimedia files. Please note that video files do not support downloading, and http protocol is required to call this interface.
Interface call request description
http request method: GET
http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
When performing the third step, it always prompts that the media_id is invalid. I saw that many people have encountered this problem before, but there is no solution. Does anyone know?
1. Interface for taking pictures or selecting pictures from the mobile phone album
wx.chooseImage({
<code>count: 1, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 }</code>
});
2. Upload image interface
wx.uploadImage({
<code>localId: '', // 需要上传的图片的本地ID,由chooseImage接口获得 isShowProgressTips: 1, // 默认为1,显示进度提示 success: function (res) { var serverId = res.serverId; // 返回图片的服务器端ID }</code>
});
3. Download multimedia files
The public account can call this interface to obtain multimedia files. Please note that video files do not support downloading, and http protocol is required to call this interface.
Interface call request description
http request method: GET
http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
When performing the third step, it always prompts that the media_id is invalid. I saw that many people have encountered this problem before, but there is no solution. Does anyone know?
I have done this function and have never encountered this problem;
Are you sure that media_id is the server-side ID of the image?
It has been solved because of the access_token problem. The access_token used before will change within 7200 seconds. After that, it can be changed to re-obtain the access_token every time
But this is not a solution. WeChat has restrictions on the frequency of acquisition