文章目录[隐藏]

前言说明

昨天有位会员朋友说需要播放微信公众号的视频,后来发了我案例,于是我看了一下过程,微信公众号里上传的视频分享出来是一个零时链接,也就是说真实的视频地址是动态,所以是没法直接调用的,后面发现工程里微信公众号视频解析规则接口其实是官方的,下面我们来看看具体的案例!

案例参考

接口地址

http://mp.weixin.qq.com/mp/videoplayer?action=get_mp_video_play_url&vid=

视频示例

http://mpvideo.qpic.cn/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10002.mp4?dis_k=de3e9a805c59c87bfb3127c0b552ffa1&dis_t=1661668930&spec_id=undefined1661668909&vid=wxv_2550317308674686977&format_id=10002

其中我们只需要“vid”这个值,也就是“wxv_2550317308674686977”

解析微信公众号视频真实地址说明插图

 

解析方式

接口+vid,也就是

http://mp.weixin.qq.com/mp/videoplayer?action=get_mp_video_play_url&vid=wxv_2550317308674686977

得到结果

返回JSON结果,也就是真实的视频链接,含多种清晰度

{
    "base_resp": {
        "ret": 0
    },
    "url_info": [{
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10002.mp4?dis_k=874a8e8bb7635bf10d336c0b393ab367&dis_t=1661758779",
        "format_id": 10002,
        "duration_ms": 211633,
        "filesize": 42584467,
        "width": 1920,
        "height": 1080,
        "video_quality_level": 3,
        "video_quality_wording": "超清"
    }, {
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10003.mp4?dis_k=3a90ca54161817d18089c768f8a6a57d&dis_t=1661758779",
        "format_id": 10003,
        "duration_ms": 211633,
        "filesize": 14079435,
        "width": 854,
        "height": 480,
        "video_quality_level": 2,
        "video_quality_wording": "高清"
    }, {
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10004.mp4?dis_k=9dabe3ab97942a671c52af73dcfe63d1&dis_t=1661758779",
        "format_id": 10004,
        "duration_ms": 211633,
        "filesize": 8859947,
        "width": 854,
        "height": 480,
        "video_quality_level": 1,
        "video_quality_wording": "流畅"
    }, {
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10102.mp4?dis_k=d858da046cd1d9eaa76998c570e3511d&dis_t=1661758779",
        "format_id": 10102,
        "duration_ms": 211633,
        "filesize": 25595351,
        "width": 1920,
        "height": 1080,
        "video_quality_level": 3,
        "video_quality_wording": "超清"
    }, {
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10103.mp4?dis_k=70a3240b873a1f79986b569bb0f44522&dis_t=1661758779",
        "format_id": 10103,
        "duration_ms": 211633,
        "filesize": 13441529,
        "width": 1280,
        "height": 720,
        "video_quality_level": 2,
        "video_quality_wording": "高清"
    }, {
        "url": "http:\/\/mpvideo.qpic.cn\/0bc3suaa6aaaieaahyikmnrvbfodb6kqadya.f10104.mp4?dis_k=d8e323794f3769563fa93e472a47a4ac&dis_t=1661758779",
        "format_id": 10104,
        "duration_ms": 211633,
        "filesize": 9434062,
        "width": 854,
        "height": 480,
        "video_quality_level": 1,
        "video_quality_wording": "流畅"
    }],
    "is_mp_video_delete": 0,
    "is_mp_video_forbid": 0,
    "is_mp_video_urgent_state": 0,
    "title": "yoguslawiya kiska",
    "is_mp_video_checking": 0,
    "is_mp_video_check_fail": 0,
    "is_appmsg_unauthorized": 0,
    "is_mp_video_transing": 0,
    "danmu_info": {
        "is_allow_danmu": 1,
        "is_allow_post_danmu": 1
    }
}

实际运用

1.我们可以视使用PHP来GET或POST,比如新建“vx.php”实际代码如下:

隐藏内容

此处内容需要权限查看

  • 普通2积分
  • 永久会员免费推荐

2.这样我们就可以解析调用播放了,当然也可以用JS来实现,调用如下

你的域名/vx.php?wxv=wxv_2550317308674686977

 

3.这样就只直接输出真实的视频地址了

 

发表回复

后才能评论