Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持使用代理访问微信接口 #556

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open

Conversation

Caisin
Copy link

@Caisin Caisin commented Apr 24, 2022

统一管理大量公众号时候就可以不用配置白名单,对管理大量公众号很有用

Copy link
Owner

@silenceper silenceper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一点小修改,另外ci的错误修正一下

Comment on lines +146 to +150
client := req.C()
if proxyUrl != "" {
client.SetProxyURL(proxyUrl)
}
resp, err := client.R().Get(url)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分可以直接封装在util.HTTPGetWithProxy方法中

@@ -124,7 +127,7 @@ func (ak *WorkAccessToken) GetAccessToken() (accessToken string, err error) {

// cache失效,从微信服务器获取
var resAccessToken ResAccessToken
resAccessToken, err = GetTokenFromServer(fmt.Sprintf(workAccessTokenURL, ak.CorpID, ak.CorpSecret))
resAccessToken, err = GetTokenFromServer(fmt.Sprintf(workAccessTokenURL, ak.CorpID, ak.CorpSecret), ak.cacheKeyPrefix)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不是传入ak.cacheKeyPrefix

Comment on lines +1 to +22
package core

import (
"github.com/imroc/req/v3"
"github.com/silenceper/wechat/v2/cache"
)

// Config .config for 微信公众号
type Config struct {
AppID string `json:"app_id"` // appid
AppSecret string `json:"app_secret"` // appsecret
ProxyUrl string `json:"proxy_url"` // 代理url
Cache cache.Cache
}

func (c *Config) Req() *req.Request {
client := req.C()
if c.ProxyUrl != "" {
client.SetProxyURL(c.ProxyUrl)
}
return client.R()
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个core我理解是抽象公共的配置字段吧,是ok的

目前只有ProxyUrl,Cache两个字段是公共的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants