feat: 回贴 API(新)
This commit is contained in:
parent
e897a03084
commit
ede1694863
|
|
@ -1191,4 +1191,28 @@ interface ITiebaApi {
|
|||
): Flow<ThreadListResponse>
|
||||
|
||||
fun syncFlow(clientId: String? = null): Flow<Sync>
|
||||
|
||||
|
||||
/**
|
||||
* 回贴(App 接口)
|
||||
*
|
||||
* **需登录**
|
||||
*
|
||||
* @param forumId 吧 ID
|
||||
* @param forumName 吧名
|
||||
* @param threadId 贴子 ID
|
||||
* @param tbs tbs
|
||||
* @param content 回复内容
|
||||
* @param postId 回复楼 ID,为空则回复贴子
|
||||
* @param replyUserId 楼中楼回复用户 ID
|
||||
*/
|
||||
fun addPostFlow(
|
||||
content: String,
|
||||
forumId: String,
|
||||
forumName: String,
|
||||
threadId: String,
|
||||
tbs: String,
|
||||
postId: String? = null,
|
||||
replyUserId: String? = null
|
||||
): Flow<AddPostBean>
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ import com.huanchengfly.tieba.post.api.buildProtobufRequestBody
|
|||
import com.huanchengfly.tieba.post.api.getScreenHeight
|
||||
import com.huanchengfly.tieba.post.api.getScreenWidth
|
||||
import com.huanchengfly.tieba.post.api.interfaces.ITiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.AddPostBean
|
||||
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
||||
import com.huanchengfly.tieba.post.api.models.CheckReportBean
|
||||
import com.huanchengfly.tieba.post.api.models.CollectDataBean
|
||||
|
|
@ -943,4 +944,30 @@ object MixedTiebaApiImpl : ITiebaApi {
|
|||
|
||||
override fun syncFlow(clientId: String?): Flow<Sync> =
|
||||
RetrofitTiebaApi.OFFICIAL_TIEBA_API.sync(clientId)
|
||||
|
||||
override fun addPostFlow(
|
||||
content: String,
|
||||
forumId: String,
|
||||
forumName: String,
|
||||
threadId: String,
|
||||
tbs: String,
|
||||
postId: String?,
|
||||
replyUserId: String?
|
||||
): Flow<AddPostBean> {
|
||||
return RetrofitTiebaApi.OFFICIAL_TIEBA_API.addPostFlow(
|
||||
content,
|
||||
forumId,
|
||||
forumName,
|
||||
tbs,
|
||||
threadId,
|
||||
quoteId = postId,
|
||||
replyUserId = replyUserId ?: if (postId == null) "null" else "",
|
||||
repostId = postId,
|
||||
is_addition = if (postId == null) null else "0",
|
||||
is_barrage = if (postId == null) "0" else null,
|
||||
is_giftpost = if (postId == null) null else "0",
|
||||
is_twzhibo_thread = if (postId == null) null else "0",
|
||||
post_from = if (postId == null) "3" else "11"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.huanchengfly.tieba.post.api.models
|
||||
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class AddPostBean(
|
||||
@SerializedName("anti_stat")
|
||||
val antiStat: AntiStat = AntiStat(),
|
||||
@SerializedName("contri_info")
|
||||
val contriInfo: List<Any> = listOf(),
|
||||
val ctime: Int = 0,
|
||||
@SerializedName("error_code")
|
||||
val errorCode: String = "",
|
||||
val exp: Exp = Exp(),
|
||||
val info: Info = Info(),
|
||||
val logid: Long = 0,
|
||||
val msg: String = "",
|
||||
val opgroup: String = "",
|
||||
val pid: String = "",
|
||||
@SerializedName("pre_msg")
|
||||
val preMsg: String = "",
|
||||
@SerializedName("server_time")
|
||||
val serverTime: String = "",
|
||||
val tid: String = "",
|
||||
val time: Int = 0
|
||||
) {
|
||||
data class AntiStat(
|
||||
@SerializedName("block_stat")
|
||||
val blockStat: String = "",
|
||||
@SerializedName("days_tofree")
|
||||
val daysTofree: String = "",
|
||||
@SerializedName("has_chance")
|
||||
val hasChance: String = "",
|
||||
@SerializedName("hide_stat")
|
||||
val hideStat: String = "",
|
||||
@SerializedName("vcode_stat")
|
||||
val vcodeStat: String = ""
|
||||
)
|
||||
|
||||
data class Exp(
|
||||
@SerializedName("color_msg")
|
||||
val colorMsg: String = "",
|
||||
@SerializedName("current_level")
|
||||
val currentLevel: String = "",
|
||||
@SerializedName("current_level_max_exp")
|
||||
val currentLevelMaxExp: String = "",
|
||||
val old: String = "",
|
||||
@SerializedName("pre_msg")
|
||||
val preMsg: String = ""
|
||||
)
|
||||
|
||||
data class Info(
|
||||
@SerializedName("access_state")
|
||||
val accessState: List<Any> = listOf(),
|
||||
@SerializedName("confilter_hitwords")
|
||||
val confilterHitwords: List<Any> = listOf(),
|
||||
@SerializedName("need_vcode")
|
||||
val needVcode: String = "",
|
||||
@SerializedName("pass_token")
|
||||
val passToken: String = "",
|
||||
@SerializedName("vcode_md5")
|
||||
val vcodeMd5: String = "",
|
||||
@SerializedName("vcode_prev_type")
|
||||
val vcodePrevType: String = "",
|
||||
@SerializedName("vcode_type")
|
||||
val vcodeType: String = ""
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit
|
||||
|
||||
import android.os.Build
|
||||
import android.webkit.WebView
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.api.Header
|
||||
import com.huanchengfly.tieba.post.api.Param
|
||||
|
|
@ -46,6 +47,7 @@ object RetrofitTiebaApi {
|
|||
internal val randomClientId = "wappc_${initTime}_${(Math.random() * 1000).roundToInt()}"
|
||||
private val stParamInterceptor = StParamInterceptor()
|
||||
private val connectionPool = ConnectionPool(32, 5, TimeUnit.MINUTES)
|
||||
private val defaultUserAgent = WebView(App.INSTANCE).settings.userAgentString
|
||||
|
||||
private val defaultCommonParamInterceptor = CommonParamInterceptor(
|
||||
Param.BDUSS to { AccountUtil.getBduss() },
|
||||
|
|
@ -86,9 +88,14 @@ object RetrofitTiebaApi {
|
|||
val WEB_TIEBA_API: WebTiebaApi by lazy {
|
||||
createJsonApi<WebTiebaApi>("https://tieba.baidu.com/",
|
||||
CommonHeaderInterceptor(
|
||||
Header.ACCEPT_LANGUAGE to { Header.ACCEPT_LANGUAGE_VALUE },
|
||||
Header.USER_AGENT to { "$defaultUserAgent tieba/11.10.8.6 skin/default" },
|
||||
Header.CUID to { CuidUtils.getNewCuid() },
|
||||
Header.CUID_GALAXY2 to { CuidUtils.getNewCuid() },
|
||||
Header.CUID_GID to { "" },
|
||||
Header.CUID_GALAXY3 to { UIDUtil.getAid() },
|
||||
Header.CLIENT_USER_TOKEN to { AccountUtil.getUid() },
|
||||
Header.CHARSET to { "UTF-8" },
|
||||
Header.HOST to { "tieba.baidu.com" },
|
||||
Header.USER_AGENT to { "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.0 Mobile Safari/537.36 Edg/103.0.1264.2" }
|
||||
),
|
||||
AddCookieInterceptor)
|
||||
}
|
||||
|
|
@ -124,6 +131,7 @@ object RetrofitTiebaApi {
|
|||
Header.CUID_GALAXY3 to { UIDUtil.getAid() },
|
||||
Header.CLIENT_TYPE to { "2" },
|
||||
Header.CHARSET to { "UTF-8" },
|
||||
"client_logid" to { "$initTime" }
|
||||
),
|
||||
defaultCommonParamInterceptor + CommonParamInterceptor(
|
||||
Param.CUID to { CuidUtils.getNewCuid() },
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ interface OfficialTiebaApi {
|
|||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@retrofit2.http.Header("thread_id") threadIdHeader: String = threadId,
|
||||
@retrofit2.http.Header("client_logid") clientLogidHeader: String = "${System.currentTimeMillis()}",
|
||||
): Call<ThreadContentBean>
|
||||
|
||||
@POST("/c/f/pb/page")
|
||||
|
|
@ -56,7 +55,6 @@ interface OfficialTiebaApi {
|
|||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@retrofit2.http.Header("thread_id") threadIdHeader: String = threadId,
|
||||
@retrofit2.http.Header("client_logid") clientLogidHeader: String = "${System.currentTimeMillis()}",
|
||||
): Call<ThreadContentBean>
|
||||
|
||||
@POST("/c/f/pb/page")
|
||||
|
|
@ -77,7 +75,6 @@ interface OfficialTiebaApi {
|
|||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@retrofit2.http.Header("thread_id") threadIdHeader: String = threadId,
|
||||
@retrofit2.http.Header("client_logid") clientLogidHeader: String = "${System.currentTimeMillis()}",
|
||||
): Deferred<ApiResult<ThreadContentBean>>
|
||||
|
||||
@POST("/c/f/pb/page")
|
||||
|
|
@ -98,7 +95,6 @@ interface OfficialTiebaApi {
|
|||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@retrofit2.http.Header("thread_id") threadIdHeader: String = threadId,
|
||||
@retrofit2.http.Header("client_logid") clientLogidHeader: String = "${System.currentTimeMillis()}",
|
||||
): Deferred<ApiResult<ThreadContentBean>>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -353,7 +349,7 @@ interface OfficialTiebaApi {
|
|||
@Headers(
|
||||
"${Header.COOKIE}: ka=open",
|
||||
"${Header.DROP_HEADERS}: ${Header.CHARSET},${Header.CLIENT_TYPE}",
|
||||
"${Header.NO_COMMON_PARAMS}: ${Param.OAID},${Param.CLIENT_TYPE}",
|
||||
"${Header.NO_COMMON_PARAMS}: ${Param.OAID}",
|
||||
)
|
||||
@POST("/c/s/sync")
|
||||
@FormUrlEncoded
|
||||
|
|
@ -376,4 +372,46 @@ interface OfficialTiebaApi {
|
|||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("stoken") sToken: String? = AccountUtil.getSToken(),
|
||||
): Flow<Sync>
|
||||
|
||||
@Headers(
|
||||
"${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}",
|
||||
"${Header.COOKIE}: ka=open",
|
||||
"${Header.DROP_HEADERS}: ${Header.CHARSET},${Header.CLIENT_TYPE}",
|
||||
"${Header.NO_COMMON_PARAMS}: ${Param.OAID}",
|
||||
)
|
||||
@POST("/c/c/post/add")
|
||||
@FormUrlEncoded
|
||||
fun addPostFlow(
|
||||
@Field("content") content: String,
|
||||
@Field("fid") forumId: String,
|
||||
@Field("kw") forumName: String,
|
||||
@Field("tbs") tbs: String,
|
||||
@Field("tid") threadId: String,
|
||||
@Field("quote_id") quoteId: String? = null,
|
||||
@Field("repostid") repostId: String? = null,
|
||||
@Field("reply_uid") replyUserId: String = "null",
|
||||
@Field("name_show") nameShow: String? = AccountUtil.getLoginInfo()?.nameShow,
|
||||
@Field("anonymous") anonymous: String = "1",
|
||||
@Field("authsid") authsid: String = "null",
|
||||
@Field("barrage_time") barrage_time: String = "0",
|
||||
@Field("can_no_forum") can_no_forum: String = "0",
|
||||
@Field("entrance_type") entrance_type: String = "0",
|
||||
@Field("from_fourm_id") from_fourm_id: String = "null",
|
||||
@Field("is_ad") is_ad: String = "0",
|
||||
@Field("is_addition") is_addition: String? = null,
|
||||
@Field("is_barrage") is_barrage: String? = "0",
|
||||
@Field("is_feedback") is_feedback: String = "0",
|
||||
@Field("is_giftpost") is_giftpost: String? = null,
|
||||
@Field("is_twzhibo_thread") is_twzhibo_thread: String? = null,
|
||||
@Field("new_vcode") new_vcode: String = "1",
|
||||
@Field("post_from") post_from: String = "3",
|
||||
@Field("takephoto_num") takephoto_num: String = "0",
|
||||
@Field("v_fid") v_fid: String = "",
|
||||
@Field("v_fname") v_fname: String = "",
|
||||
@Field("vcode_tag") vcode_tag: String = "12",
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("stoken") sToken: String? = AccountUtil.getSToken(),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
): Flow<AddPostBean>
|
||||
}
|
||||
Loading…
Reference in New Issue