Java 请求获取作品详情

本示例使用 Java 代码请求画世界 API 获取作品详情,并解析返回的 JSON 数据。

请求 URL:

https://app.huashijie.art/api/work/detailV2?visitorId=-1&workId=180830738&cur_user_id=-1&platform=android&os_version=28&version_code=217&device_brand=vivo&device_model=vivo%20X21&token=&channel=vivo

请求参数:

| 参数名称 | 说明 | 类型 | 示例值 |
|---|---|---|---| | visitorId | 访问者 ID | int | -1 | | workId | 作品 ID | int | 180830738 | | cur_user_id | 当前用户 ID | int | -1 | | platform | 平台 | string | android | | os_version | 操作系统版本 | int | 28 | | version_code | 版本号 | int | 217 | | device_brand | 设备品牌 | string | vivo | | device_model | 设备型号 | string | vivo X21 | | token | 用户 token | string | | | channel | 渠道 | string | vivo |

返回结果:

{
  "status": 1,
  "msg": "success",
  "data": {
    "id": 180830853,
    "userId": 15281277,
    "status": 1,
    "targetType": 2,
    "targetValue": 72924806,
    "content": '可以求个花花嘛(ㅇㅅㅇ❀)',
    "commentCount": 19,
    "tags": "二创,稿,插画",
    "isLike": 0,
    "isCollect": 0,
    "createTime": "2023-09-14 15:27:29",
    "hasPic": 1,
    "recommendType": 4,
    "factionIds": "20,3830,1583",
    "app": 1,
    "isToped": false,
    "topTime": "2023-09-14 15:27:29",
    "likeCount": 113,
    "hotPoint": 188,
    "giftCount": 15,
    "user": {
      "id": 15281277,
      "srcType": 2,
      "createTime": "2022-01-29 23:43:26",
      "nick": "小小小漱",
      "avatar": "http://bsyimgv2.pandapaint.net/v2/avatar/user/15281277/1694675609980.png?x-oss-process=style/work_cover_med&image_process=format,WEBP",
      "sex": 1,
      "level": 4,
      "addr": "水果星",
      "instruction": "",
      "certificationSig": 0,
      "certificationDes": "",
      "isFrost": 0,
      "worksCount": 13,
      "fansCount": 243,
      "attentionCount": 37,
      "vipId": 1,
      "vipStartTime": "2023-09-14 15:19:32",
      "vipExpireTime": "2023-10-14 15:19:32",
      "vipLevel": 1,
      "backgroundUrl": "http://bsyimg.pandapaint.net/background/2023/03/19/AE1F3A7D55B84A498A43C9C810F0CFCD.jpg",
      "lastLoginTime": "2023-09-16 22:24:19",
      "exp": 1655,
      "app": 1,
      "headBox": 3,
      "isFollow": 0,
      "maskState": 0,
      "realName": "小小小漱",
      "profile": []
    },
    "targetStatus": 1,
    "minAge": 0,
    "multiImages": [
      {
        "type": 1,
        "imgPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
        "noWmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
        "orgPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg",
        "orgWmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg",
        "wmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
        "filePath": "GOmkukYB2Ap8EQ3JLZDIUW58ibRjYlIciPOFQSJa4B/5MjEPSNIntQbA73ZwH5EO3nN+Ewc6HLTPE6OF5RnG5XS2rMxirz8hHA8xFvn5wOE=",
        "width": 1618,
        "height": 2157,
        "device": "画世界_iOS 1618x2157",
        "totalLineCount": 9426,
        "paintVer": 31,
        "coverWidth": 1618,
        "coverHeight": 2157,
        "paintPkgSize": 10639992,
        "videoPath": "",
        "imgId": 72924806
      }
    ],
    "pic": {
      "type": 1,
      "imgPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
      "noWmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
      "orgPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg",
      "orgWmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg",
      "wmPath": "http://bsyimg.pandapaint.net/v2/work_cover/user/15281277/1694676444675.jpg?x-oss-process=image/resize,m_lfit,w_1080,limit_0/auto-orient,1/sharpen,100",
      "filePath": "GOmkukYB2Ap8EQ3JLZDIUW58ibRjYlIciPOFQSJa4B/5MjEPSNIntQbA73ZwH5EO3nN+Ewc6HLTPE6OF5RnG5XS2rMxirz8hHA8xFvn5wOE=",
      "width": 1618,
      "height": 2157,
      "device": "画世界_iOS 1618x2157",
      "totalLineCount": 9426,
      "paintVer": 31,
      "coverWidth": 1618,
      "coverHeight": 2157,
      "paintPkgSize": 10639992,
      "videoPath": "",
      "imgId": 72924806,
      "animFrameCount": 0
    },
    "isMultiPaint": false,
    "faction": [
      {
        "id": 20,
        "name": "二创",
        "type": 2,
        "isToped": false,
        "isBoutique": false,
        "coverUrl": "http://bsyimg.pandapaint.net/images/topic/%E4%BA%8C%E5%88%9B.png",
        "canBlock": false
      },
      {
        "id": 3830,
        "name": "稿",
        "type": 2,
        "isToped": false,
        "isBoutique": false,
        "coverUrl": "http://bsyimg.pandapaint.net/topic/2018/09/25/a100af90891e4c5e9c04fe968e36eaa1.jpg",
        "canBlock": true
      },
      {
        "id": 1583,
        "name": "插画",
        "type": 2,
        "isToped": false,
        "isBoutique": false,
        "coverUrl": "http://bsyimg.pandapaint.net/topic/2018/09/15/4cf8256ae3094fc280d976024913e257.jpg",
        "canBlock": true
      }
    ],
    "noScreenshot": "",
    "recommend": {
      ...
    }
  }
}

代码示例:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;

public class WorkDetailRequest {

  public static void main(String[] args) throws Exception {
    String url = "https://app.huashijie.art/api/work/detailV2?visitorId=-1&workId=180830738&cur_user_id=-1&platform=android&os_version=28&version_code=217&device_brand=vivo&device_model=vivo%20X21&token=&channel=vivo";
    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    con.setRequestMethod("GET");
    int responseCode = con.getResponseCode();
    if (responseCode == HttpURLConnection.HTTP_OK) {
      BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
      String inputLine;
      StringBuffer response = new StringBuffer();
      while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
      }
      in.close();
      // 解析 JSON 数据
      JSONObject jsonObject = new JSONObject(response.toString());
      // 获取作品详情数据
      JSONObject workData = jsonObject.getJSONObject("data");
      System.out.println(workData);
    } else {
      System.out.println("请求失败: " + responseCode);
    }
  }
}

注意:

  • 以上代码仅供参考,实际使用中需要根据具体情况进行修改。
  • 请注意 API 访问频率限制,避免过度请求。
  • 详细的 API 文档请参考画世界开发者平台。
Java 请求接口获取作品详情 - 画世界 API

原文地址: https://www.cveoy.top/t/topic/iIJk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录