feat: 使用极速版 API 规避点赞风控

This commit is contained in:
HuanCheng65 2023-07-14 11:07:22 +08:00
parent ab7e442ea8
commit 5adeee3cad
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
10 changed files with 81 additions and 11 deletions

View File

@ -54,22 +54,39 @@ object Header {
object Param { object Param {
const val ACTIVE_TIMESTAMP = "active_timestamp"
const val ANDROID_ID = "android_id"
const val BAIDU_ID = "baiduid"
const val BDUSS = "BDUSS" const val BDUSS = "BDUSS"
const val BRAND = "brand"
const val CLIENT_VERSION = "_client_version" const val CLIENT_VERSION = "_client_version"
const val CLIENT_TYPE = "_client_type" const val CLIENT_TYPE = "_client_type"
const val CLIENT_ID = "_client_id" const val CLIENT_ID = "_client_id"
const val PHONE_IMEI = "_phone_imei" const val PHONE_IMEI = "_phone_imei"
const val CMODE = "cmode"
const val CUID = "cuid" const val CUID = "cuid"
const val CUID_GALAXY2 = "cuid_galaxy2" const val CUID_GALAXY2 = "cuid_galaxy2"
const val CUID_GALAXY3 = "c3_aid" const val CUID_GALAXY3 = "c3_aid"
const val OAID = "oaid" const val OAID = "oaid"
const val CUID_GID = "cuid_gid" const val CUID_GID = "cuid_gid"
const val EVENT_DAY = "event_day"
const val EXTRA = "extra"
const val FIRST_INSTALL_TIME = "first_install_time"
const val FROM = "from" const val FROM = "from"
const val NET_TYPE = "net_type" const val FRAMEWORK_VER = "framework_ver"
const val IS_TEENAGER = "is_teenager"
const val LAST_UPDATE_TIME = "last_update_time"
const val MAC = "mac"
const val MODEL = "model" const val MODEL = "model"
const val NET_TYPE = "net_type"
const val OS_VERSION = "_os_version" const val OS_VERSION = "_os_version"
const val TIMESTAMP = "timestamp" const val SAMPLE_ID = "sample_id"
const val SDK_VER = "sdk_ver"
const val SIGN = "sign" const val SIGN = "sign"
const val START_SCHEME = "start_scheme"
const val START_TYPE = "start_type"
const val SUBAPP_TYPE = "subapp_type" const val SUBAPP_TYPE = "subapp_type"
const val STOKEN = "stoken" const val STOKEN = "stoken"
const val SWAN_GAME_VER = "swan_game_ver"
const val TIMESTAMP = "timestamp"
} }

View File

@ -96,9 +96,10 @@ interface ITiebaApi {
*/ */
fun opAgreeFlow( fun opAgreeFlow(
threadId: String, threadId: String,
postId: String,
opType: Int, opType: Int,
postId: String? = null, objType: Int,
isSubPost: Boolean = false, agreeType: Int = 2,
): Flow<AgreeBean> ): Flow<AgreeBean>
/** /**

View File

@ -160,15 +160,17 @@ object MixedTiebaApiImpl : ITiebaApi {
override fun opAgreeFlow( override fun opAgreeFlow(
threadId: String, threadId: String,
postId: String,
opType: Int, opType: Int,
postId: String?, objType: Int,
isSubPost: Boolean agreeType: Int,
): Flow<AgreeBean> = ): Flow<AgreeBean> =
RetrofitTiebaApi.OFFICIAL_TIEBA_API.agreeFlow( RetrofitTiebaApi.MINI_TIEBA_API.opAgreeFlow(
threadId, threadId,
postId, postId,
opType = opType, opType = opType,
objType = if (postId == null) 3 else if (isSubPost) 2 else 1 objType = objType,
agreeType = agreeType
) )
override fun disagreeFlow( override fun disagreeFlow(

View File

@ -28,6 +28,7 @@ import com.huanchengfly.tieba.post.api.retrofit.interfaces.OfficialTiebaApi
import com.huanchengfly.tieba.post.api.retrofit.interfaces.WebTiebaApi import com.huanchengfly.tieba.post.api.retrofit.interfaces.WebTiebaApi
import com.huanchengfly.tieba.post.toJson import com.huanchengfly.tieba.post.toJson
import com.huanchengfly.tieba.post.utils.AccountUtil import com.huanchengfly.tieba.post.utils.AccountUtil
import com.huanchengfly.tieba.post.utils.CacheUtil.base64Encode
import com.huanchengfly.tieba.post.utils.ClientUtils import com.huanchengfly.tieba.post.utils.ClientUtils
import com.huanchengfly.tieba.post.utils.CuidUtils import com.huanchengfly.tieba.post.utils.CuidUtils
import com.huanchengfly.tieba.post.utils.MobileInfoUtil import com.huanchengfly.tieba.post.utils.MobileInfoUtil
@ -37,6 +38,9 @@ import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.wire.WireConverterFactory import retrofit2.converter.wire.WireConverterFactory
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -128,6 +132,7 @@ object RetrofitTiebaApi {
"http://c.tieba.baidu.com/", "http://c.tieba.baidu.com/",
CommonHeaderInterceptor( CommonHeaderInterceptor(
Header.USER_AGENT to { "bdtb for Android 12.25.1.0" }, Header.USER_AGENT to { "bdtb for Android 12.25.1.0" },
Header.COOKIE to { "CUID=${CuidUtils.getNewCuid()};ka=open;TBBRAND=${Build.MODEL};BAIDUID=${ClientUtils.baiduId};" },
Header.CUID to { CuidUtils.getNewCuid() }, Header.CUID to { CuidUtils.getNewCuid() },
Header.CUID_GALAXY2 to { CuidUtils.getNewCuid() }, Header.CUID_GALAXY2 to { CuidUtils.getNewCuid() },
Header.CUID_GID to { "" }, Header.CUID_GID to { "" },
@ -137,10 +142,33 @@ object RetrofitTiebaApi {
"client_logid" to { "$initTime" } "client_logid" to { "$initTime" }
), ),
defaultCommonParamInterceptor + CommonParamInterceptor( defaultCommonParamInterceptor + CommonParamInterceptor(
Param.ACTIVE_TIMESTAMP to { ClientUtils.activeTimestamp.toString() },
Param.ANDROID_ID to { base64Encode(UIDUtil.getAndroidId("000")) },
Param.BAIDU_ID to { ClientUtils.baiduId },
Param.BRAND to { Build.BRAND },
Param.CMODE to { "1" },
Param.CUID to { CuidUtils.getNewCuid() }, Param.CUID to { CuidUtils.getNewCuid() },
Param.CUID_GALAXY2 to { CuidUtils.getNewCuid() }, Param.CUID_GALAXY2 to { CuidUtils.getNewCuid() },
Param.CUID_GID to { "" }, Param.CUID_GID to { "" },
Param.EVENT_DAY to {
SimpleDateFormat("yyyyMdd", Locale.getDefault()).format(
Date(
System.currentTimeMillis()
)
)
},
Param.EXTRA to { "" },
Param.FIRST_INSTALL_TIME to { App.Config.appFirstInstallTime.toString() },
Param.FRAMEWORK_VER to { "3340042" },
Param.FROM to { "tieba" }, Param.FROM to { "tieba" },
Param.IS_TEENAGER to { "0" },
Param.LAST_UPDATE_TIME to { App.Config.appLastUpdateTime.toString() },
Param.MAC to { "02:00:00:00:00:00" },
Param.SAMPLE_ID to { ClientUtils.sampleId },
Param.SDK_VER to { "2.34.0" },
Param.START_SCHEME to { "" },
Param.START_TYPE to { "1" },
Param.SWAN_GAME_VER to { "1038000" },
Param.CLIENT_VERSION to { "12.25.1.0" }, Param.CLIENT_VERSION to { "12.25.1.0" },
Param.CUID_GALAXY3 to { UIDUtil.getAid() }, Param.CUID_GALAXY3 to { UIDUtil.getAid() },
Param.OAID to { OAID().toJson() }, Param.OAID to { OAID().toJson() },

View File

@ -107,6 +107,21 @@ interface MiniTiebaApi {
@Field("stoken") stoken: String = AccountUtil.getSToken()!! @Field("stoken") stoken: String = AccountUtil.getSToken()!!
): Call<AgreeBean> ): Call<AgreeBean>
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
@POST("/c/c/agree/opAgree")
@FormUrlEncoded
fun opAgreeFlow(
@Field("thread_id") threadId: String,
@Field("post_id") postId: String,
@Field("agree_type") agreeType: Int = 2,
@Field("obj_type") objType: Int = 3,
@Field("op_type") opType: Int = 0,
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
@Field("cuid_gid") cuid_gid: String = "",
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
): Flow<AgreeBean>
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}") @Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
@POST("/c/c/agree/opAgree") @POST("/c/c/agree/opAgree")
@FormUrlEncoded @FormUrlEncoded

View File

@ -205,7 +205,9 @@ private class ForumThreadListPartialChangeProducer(val type: ForumThreadListType
private fun ForumThreadListUiIntent.Agree.producePartialChange(): Flow<ForumThreadListPartialChange.Agree> = private fun ForumThreadListUiIntent.Agree.producePartialChange(): Flow<ForumThreadListPartialChange.Agree> =
TiebaApi.getInstance().opAgreeFlow( TiebaApi.getInstance().opAgreeFlow(
threadId.toString(), threadId.toString(),
postId.toString(),
hasAgree, hasAgree,
objType = 3
).map<AgreeBean, ForumThreadListPartialChange.Agree> { ).map<AgreeBean, ForumThreadListPartialChange.Agree> {
ForumThreadListPartialChange.Agree.Success( ForumThreadListPartialChange.Agree.Success(
threadId, threadId,

View File

@ -79,7 +79,7 @@ class ConcernViewModel @Inject constructor() :
private fun ConcernUiIntent.Agree.producePartialChange(): Flow<ConcernPartialChange.Agree> = private fun ConcernUiIntent.Agree.producePartialChange(): Flow<ConcernPartialChange.Agree> =
TiebaApi.getInstance().opAgreeFlow( TiebaApi.getInstance().opAgreeFlow(
threadId.toString(), hasAgree threadId.toString(), postId.toString(), hasAgree, objType = 3
).map<AgreeBean, ConcernPartialChange.Agree> { ConcernPartialChange.Agree.Success(threadId, hasAgree xor 1) } ).map<AgreeBean, ConcernPartialChange.Agree> { ConcernPartialChange.Agree.Success(threadId, hasAgree xor 1) }
.catch { emit(ConcernPartialChange.Agree.Failure(threadId, hasAgree, it)) } .catch { emit(ConcernPartialChange.Agree.Failure(threadId, hasAgree, it)) }
.onStart { emit(ConcernPartialChange.Agree.Start(threadId, hasAgree xor 1)) } .onStart { emit(ConcernPartialChange.Agree.Start(threadId, hasAgree xor 1)) }

View File

@ -115,7 +115,7 @@ class PersonalizedViewModel @Inject constructor() :
private fun PersonalizedUiIntent.Agree.producePartialChange(): Flow<PersonalizedPartialChange.Agree> = private fun PersonalizedUiIntent.Agree.producePartialChange(): Flow<PersonalizedPartialChange.Agree> =
TiebaApi.getInstance().opAgreeFlow( TiebaApi.getInstance().opAgreeFlow(
threadId.toString(), hasAgree, threadId.toString(), postId.toString(), hasAgree, objType = 3
).map<AgreeBean, PersonalizedPartialChange.Agree> { ).map<AgreeBean, PersonalizedPartialChange.Agree> {
PersonalizedPartialChange.Agree.Success( PersonalizedPartialChange.Agree.Success(
threadId, threadId,

View File

@ -1061,6 +1061,7 @@ fun ThreadPage(
if (firstPostId != 0L) viewModel.send( if (firstPostId != 0L) viewModel.send(
ThreadUiIntent.AgreeThread( ThreadUiIntent.AgreeThread(
threadId, threadId,
firstPostId,
!hasThreadAgreed !hasThreadAgreed
) )
) )

View File

@ -359,7 +359,9 @@ class ThreadViewModel @Inject constructor() :
TiebaApi.getInstance() TiebaApi.getInstance()
.opAgreeFlow( .opAgreeFlow(
threadId.toString(), threadId.toString(),
postId.toString(),
opType = if (agree) 0 else 1, opType = if (agree) 0 else 1,
objType = 3
) )
.map<AgreeBean, ThreadPartialChange.AgreeThread> { .map<AgreeBean, ThreadPartialChange.AgreeThread> {
ThreadPartialChange.AgreeThread.Success( ThreadPartialChange.AgreeThread.Success(
@ -381,8 +383,9 @@ class ThreadViewModel @Inject constructor() :
TiebaApi.getInstance() TiebaApi.getInstance()
.opAgreeFlow( .opAgreeFlow(
threadId.toString(), threadId.toString(),
if (agree) 0 else 1,
postId.toString(), postId.toString(),
if (agree) 0 else 1,
objType = 1
) )
.map<AgreeBean, ThreadPartialChange.AgreePost> { .map<AgreeBean, ThreadPartialChange.AgreePost> {
ThreadPartialChange.AgreePost.Success( ThreadPartialChange.AgreePost.Success(
@ -469,6 +472,7 @@ sealed interface ThreadUiIntent : UiIntent {
data class AgreeThread( data class AgreeThread(
val threadId: Long, val threadId: Long,
val postId: Long,
val agree: Boolean val agree: Boolean
) : ThreadUiIntent ) : ThreadUiIntent