ACFUN登录及番剧追番列表API的简单分析

最近想更新下之前写的 WordPress 追番目录插件,出一个 AcFun API 版本。
网页端没有追番列表,我用 Fiddler 抓了下安卓移动端 AcFun APP 的包,这里记录下分析结果。

前情提要

隔壁(BiliBili)的 API 都有官方文档,而 AC 这边的 API 貌似都没公开,也找不到公开文档。没办法,只能自己上手抓包。

本处抓取的 API 仅用于学习,切勿用于商业用途,使用带来的侵权问题与本文无关。

登录

  1. 请求网址
    POST https://id.app.acfun.cn/rest/app/login/signin
    
  2. Header(多统计用字段,大多非必要)
    random: xxxx-xxxx-xxxx
    isp: CMCC
    mod: realme(RMX1931)
    acPlatform: ANDROID_PHONE
    User-agent: acvideo core/6.17.1.879(realme;RMX1931;5.1.1)
    mac: xx:xx:xx:xx:xxx
    uuid: 4ef877d8-e4d8-446e-97ef-d65a826e36cc
    deviceType: 1
    net: WIFI
    Cookie: did=xxxxx-xxxx-xxxx-xxxx-xxxx;safety_id=xxxxx
    gid: xxxxxx
    androidId: xxxxx
    appVersion: 6.17.1.879
    imei: xxxxx
    productId: 2000
    market: tencent
    resolution: 720x1280
    language: zh-cn
    udid: xxxxx-xxxx-xxxx-xxxx
    isChildPattern: false
    requestTime: 2020-03-xx 17:xx:xx.xxx
    sign: xxxxxxxx
    token: 
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 39
    Host: id.app.acfun.cn
    Connection: Keep-Alive
    Accept-Encoding: gzip
    
    • 其中,必要字段为deviceTypeContent-Type
  3. Request(application/x-www-form-urlencoded)
    username=18888888888&password=88888888
    
  4. Response(JSON)
    //成功
    {
        "mobile-check": 1,
        "group-level": 1,
        "acPassToken": "Cxxxxxxxxx",
        "mobile": "18888888888",
        "avatar": "https://imgs.aixifan.com/style/image/201907/xxxxxx.jpg",
        "auth_key": 1888888,
        "userid": 1888888,
        "first_login": false,
        "token": "5c4xxxxxxxxxxxxxxxx",
        "check_real": 1,
        "result": 0,
        "acSecurity": "xxxxxxxxx/t96Q==",
        "check_password": 0,
        "passCheck": true,
        "username": "XXXX"
    }
    //失败1,用户密码错误
    {
        "result":100001005,
        "error_msg":"帐号不存在或密码错误"
    }
    //失败2,常见于header参数错误
    {
        "result": 302560072,
        "error_msg": "[302560072]服务器忙,请稍后再试."
    }
    

追番列表

  1. 请求网址
    Get https://api-new.acfunchina.com/rest/app/feed/favorite/bangumi
    
  2. Get参数
    • count:int,返回结果的最大数量
    • pcursor:long,APP分页用的索引,值为上一页最后番剧的最后更新时间(毫秒)。
      • 多说一句,ac的追番列表用最后更新时间排序,保证最先更新的排在前边。
  3. Header(参数太多,只写必要参数)
    Cookie: (以下内容为一行,均为Cookie的字符串值)\
    did=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx; \
    safety_id=xxxxxxxxxx; \
    auth_key=1888888;userId=1888888; \
    acPasstoken=xxxx;acfun.midground.api_st=xxxx;old_token=xxxx
    
    • Cookie 为必要项,而 Cookie 内必要项为auth_keyacPasstoen
    • auth_key 的值与 userId的值相同,这是将用户 id 用做验证么。
    • 你问我怎么知道的?试出来的。
  4. Response(JSON)
    {
        "result": 0,
        "feeds": [
            {
                "groupId": "xxxxxxxxxx",
                "albumId": "5022158",
                "lastVideoName": "第十二话",
                "lastUpdateTime": "2018-12-17",
                "coverUrls": [
                    "https://tx-free-imgs.acfun.cn/cms/2019_01_17/1547693211380.jpg?imageMogr2/format/webp/quality/75!/ignore-error/1"
                ],
                "caption": "茜色少女",
                "showPlayCount": "700.4万",
                "showStowCount": "7.1万",
                "showCommentCount": "7826",
                "showSerialStatus": "全12话",
                "verticalCoverUrls": [
                    "https://tx-free-imgs.acfun.cn/cms/2019_01_17/1547693206599.jpg?imageMogr2/format/webp/quality/75!/ignore-error/1"
                ],
                "lastVideoDescription": "2018年的某一天,少女们和另一个世界的“自己”相遇了——。 高中生土宫明日架与朋友们隶属“矿石电台研究会”,在一次游戏中,她们效仿都市传说举行了“某个仪式”。不料仪式打开了平行世界,她们踏入了与日常截然不同的领域,新世界的大门就此打开",
                "updateStatus": 0,
                "isOver": true,
                "updateDayOfWeek": 1,
                "isFavorite": true,
                "description": "AcFun番剧相关信息请关注微博@AcFun新番\n2018年的某一天,少女们和另一个世界的“自己”相遇了——。\n高中生土宫明日架与朋友们隶属“矿石电台研究会”,在一次游戏中,她们效仿都市传说举行了“某个仪式”。不料仪式打开了平行世界,她们踏入了与日常截然不同的领域,新世界的大门就此打开。",
                "stowCount": 71205,
                "shareUrl": "https://www.acfun.cn/bangumi/aa5022158",
                "likeCount": 297,
                "intro": "AcFun番剧相关信息请关注微博@AcFun新番\n2018年的某一天,少女们和另一个世界的“自己”相遇了——。\n高中生土宫明日架与朋友们隶属“矿石电台研究会”,在一次游戏中,她们效仿都市传说举行了“某个仪式”。不料仪式打开了平行世界,她们踏入了与日常截然不同的领域,新世界的大门就此打开。",
                "coverImageV": "https://tx-free-imgs.acfun.cn/cms/2019_01_17/1547693206599.jpg?imageMogr2/format/webp/quality/75!/ignore-error/1",
                "coverImageH": "https://tx-free-imgs.acfun.cn/cms/2019_01_17/1547693211380.jpg?imageMogr2/format/webp/quality/75!/ignore-error/1",
                "commentCount": 7826,
                "paymentType": {
                    "value": 0,
                    "name": "免费"
                },
                "playCount": 7004075,
                "area": 1,
                "acfunOnly": true,
                "title": "茜色少女",
                "playCountShow": "700.4万",
                "firstPlayDate": 1538323200000,
                "updateWeekDay": 1,
                "updateDayTime": 39780000,
                "areaShow": "日本",
                "shareCount": 164,
                "isLike": false,
                "commentCountShow": "7826",
                "shareCountShow": "164",
                "stowCountShow": "7.1万",
                "id": 5022158,
                "lastVideoId": 6488676,
                "online": 1,
                "onlineTime": 1536567923000,
                "bangumiStyleList": [],
                "allowComment": true,
                "allowDownload": false,
                "updateDayTimeStr": "19:03",
                "lastUpdateItemName": "第十二话",
                "commentParted": false,
                "lastUpdateItemTimeStr": "18年12月更新",
                "itemCount": 12
            }
        ],
        "pcursor": "1545045917000",
        "host-name": "hb2-acfun-kcs027.aliyun",
        "requestId": "xxxxxxxxxxxxxxxxxxx"
    }
    

总结

ailicili~ (゜-゜)つロ 对瓶吹~-

梓喵出没博客(azimiao.com)版权所有,转载请注明链接:https://www.azimiao.com/5882.html
欢迎加入梓喵出没博客交流群:313732000

发表评论

*

*

评论区

  1. acer05-03 16:30 回复

    我用 Fiddler 抓了下安卓移动端 AcFun APP 的包,按照网上配置代理,证书之类的也安装到安卓手机了, 可是打开安卓app后显示没有网络,视频,评论等都加载不出来,无法抓到https。但是手机浏览器访问m.acfun.tv可以被抓包到。请问你是怎么抓到包的呢?能否告知一下抓包技巧,谢谢

    • lrhtony05-08 17:52 回复

      手机貌似要将证书移到系统目录才能抓包