本文主要是介绍微信群发接口发送视频获取media_id返回null,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
微信群发视频时:微信文档这样说道:
请注意,此处视频的media_id需通过POST请求到下述接口特别地得到:https://file.api.weixin.qq.com/cgi-bin/media/uploadvideo?access_token=ACCESS_TOKEN POST数据如下(此处media_id需通过基础支持中的上传下载多媒体文件来得到):
{"media_id": "rF4UdIMfYK3efUfyoddYRMU50zMiRmmt_l0kszupYh_SzrcW5Gaheq05p_lHuOTQ","title": "TITLE","description": "Description" }
返回将为
{"type":"video","media_id":"IhdaAQXuvJtGzwwc0abfXnzeezfO0NgPK6AQYShD8RQYMTtfzbLdBIQkQziv2XJc","created_at":1398848981 }
然后,POST下述数据(将media_id改为上一步中得到的media_id),即可进行发送
{"filter":{"is_to_all":false,"tag_id":2},"mpvideo":{"media_id":"IhdaAQXuvJtGzwwc0abfXnzeezfO0NgPK6AQYShD8RQYMTtfzbLdBIQkQziv2XJc",},"msgtype":"mpvideo" }
但我用https://file.api.weixin.qq.com/cgi-bin/media/uploadvideo?access_token=ACCESS_TOKEN 获取media_id时返回null, 这个是微信文档搞错了,正确的url应该是https://api.weixin.qq.com/cgi-bin/media/uploadvideo?access_token=ACCESS_TOKEN ,没有那个file,好像现在的微信接口都没有file.了。
$temporary_data['filename'] = $video['file_name'];
$temporary_data['content-type'] = $video['file_type'];
$temporary_data['filelength'] = $video['size'];
$video_path = ROOT_PATH . $video['file'];
$temporary_media_id = $wxClassLib->up_temporary_media("video", $video_path, $temporary_data); //上传临时素材
//获取特殊media_id
if($temporary_media_id != "")
{
$mpvideo['media_id'] = $temporary_media_id['media_id'];
$mpvideo['title'] = $video['title'];
$mpvideo['description'] = $video['digest'];
$mpmedia_id = $wxClassLib->up_mpvideo($mpvideo);
if($mpmedia_id != "")
{
$content = $mpmedia_id['media_id'];
$mpdata['media_id'] = $mpmedia_id['media_id'];
$upres = $wxClassLib->send_mass_msg('video', $tag_id, $mpdata); //群发
}
}
这篇关于微信群发接口发送视频获取media_id返回null的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!