优化:企业微信应用发送通道允许自定义API地址【通过反向代理(proxy_pass https://qyapi.weixin.qq.com;)绕过IP白名单限制】 #352

This commit is contained in:
pppscn 2023-10-21 13:12:25 +08:00
parent 8eeb2b1cc2
commit 74346b7291
2 changed files with 5 additions and 5 deletions

View File

@ -18,7 +18,7 @@ data class WeworkAgentSetting(
val proxyAuthenticator: Boolean? = false,
val proxyUsername: String? = "",
val proxyPassword: String? = "",
val customizeAPI: String = "https://qyapi.weixin.qq.com/cgi-bin",
val customizeAPI: String = "https://qyapi.weixin.qq.com",
) : Serializable {
fun getProxyTypeCheckId(): Int {

View File

@ -47,8 +47,8 @@ class WeworkAgentUtils private constructor() {
return sendTextMsg(setting, msgInfo, rule, senderIndex, logId, msgId)
}
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com/cgi-bin" else setting.customizeAPI
var getTokenUrl = "$customApi/gettoken?"
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com" else setting.customizeAPI
var getTokenUrl = "$customApi/cgi-bin/gettoken?"
getTokenUrl += "corpid=" + setting.corpID
getTokenUrl += "&corpsecret=" + setting.secret
Log.d(TAG, "getTokenUrl$getTokenUrl")
@ -141,8 +141,8 @@ class WeworkAgentUtils private constructor() {
textText["content"] = content
textMsgMap["text"] = textText
val accessToken: String by SharedPreference("access_token_" + setting.agentID, "")
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com/cgi-bin" else setting.customizeAPI
val requestUrl = "$customApi/message/send?access_token=$accessToken"
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com" else setting.customizeAPI
val requestUrl = "$customApi/cgi-bin/message/send?access_token=$accessToken"
Log.i(TAG, "requestUrl:$requestUrl")
val requestMsg: String = Gson().toJson(textMsgMap)
Log.i(TAG, "requestMsg:$requestMsg")