feat: 动态点赞/取消赞
This commit is contained in:
@ -145,6 +145,10 @@ class Api {
|
||||
// https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?host_mid=548196587&offset=&page=1&features=itemOpusStyle
|
||||
static const String followDynamic = '/x/polymer/web-dynamic/v1/feed/all';
|
||||
|
||||
// 动态点赞
|
||||
static const String likeDynamic =
|
||||
'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb';
|
||||
|
||||
// 获取稍后再看
|
||||
static const String seeYouLater = '/x/v2/history/toview';
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
class HttpString {
|
||||
static const String baseUrl = 'https://www.bilibili.com';
|
||||
static const String baseApiUrl = 'https://api.bilibili.com';
|
||||
static const String tUrl = 'https://api.vc.bilibili.com';
|
||||
}
|
||||
|
||||
@ -50,4 +50,31 @@ class DynamicsHttp {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 动态点赞
|
||||
static Future likeDynamic({
|
||||
required String? dynamicId,
|
||||
required int? up,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.likeDynamic,
|
||||
queryParameters: {
|
||||
'dynamic_id': dynamicId,
|
||||
'up': up,
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@ class Request {
|
||||
dio.interceptors.add(cookieManager);
|
||||
var cookie = await cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||
var cookie2 = await cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.tUrl));
|
||||
if (cookie.isEmpty) {
|
||||
try {
|
||||
await Request().get(HttpString.baseUrl);
|
||||
@ -45,6 +47,13 @@ class Request {
|
||||
log("setCookie, ${e.toString()}");
|
||||
}
|
||||
}
|
||||
if (cookie2.isEmpty) {
|
||||
try {
|
||||
await Request().get(HttpString.tUrl);
|
||||
} catch (e) {
|
||||
log("setCookie, ${e.toString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 移除cookie
|
||||
@ -99,7 +108,6 @@ class Request {
|
||||
options.headers['x-bili-mid'] = user.get(UserBoxKey.userMid).toString();
|
||||
}
|
||||
dio.options = options;
|
||||
|
||||
//添加拦截器
|
||||
dio.interceptors
|
||||
..add(ApiInterceptor())
|
||||
|
||||
Reference in New Issue
Block a user