Browse Source

修改接口数据格式

master v0.1.2
guzeng 3 years ago
parent
commit
7c5041e9db
3 changed files with 30 additions and 13 deletions
  1. +5
    -1
      access_token.client.go
  2. +12
    -0
      common.go
  3. +13
    -12
      send_uniform_message.client.go

+ 5
- 1
access_token.client.go View File

@ -14,7 +14,11 @@ func GetAccessToken(dbname, site_id string, appid, secret string, url ...string)
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
data := AccessTokenReq{SiteId: site_id, Dbname: dbname, Appid: appid, Secret: secret}
data := AccessTokenReq{}
data.SiteId = site_id
data.Dbname = dbname
data.Appid = appid
data.Secret = secret
data_json, err := json.Marshal(data) data_json, err := json.Marshal(data)
if err != nil { if err != nil {


+ 12
- 0
common.go View File

@ -22,6 +22,18 @@ type AccessTokenRes struct {
AccessToken string AccessToken string
} }
type UniformMessageReq struct {
Req
Appid string
Secret string
Touser string
MpAppid string
TemplateId string
Url string
MiniProgram string
Data string
}
func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) { func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) {
var wx_rpc_url string = "127.0.0.1:7969" var wx_rpc_url string = "127.0.0.1:7969"


+ 13
- 12
send_uniform_message.client.go View File

@ -30,25 +30,26 @@ type UniformMessageReq struct {
* touser 小程序openid * touser 小程序openid
* mp_appid 关联公众号appid要求与小程序有绑定且同主体 * mp_appid 关联公众号appid要求与小程序有绑定且同主体
* temp_id 公众号模板id * temp_id 公众号模板id
* url 跳转的url
* redirect_url 跳转的url
* mini_program 公众号模板消息所要跳转的小程序小程序的必须与公众号具有绑定关系 * mini_program 公众号模板消息所要跳转的小程序小程序的必须与公众号具有绑定关系
* data 公众号模板消息的数据 * data 公众号模板消息的数据
*/ */
func SendUniformMessage(dbname, site_id string, appid, secret, touser, mp_appid, temp_id, url, mini_program, data string, url ...string) (*WxApiRes, error) {
func SendUniformMessage(dbname, site_id string, appid, secret, touser, mp_appid, temp_id, redirect_url, mini_program, data string, url ...string) (*WxApiRes, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
data["dbname"] = dbname
data["site_id"] = site_id
data["appid"] = appid
data["secret"] = secret
data["touser"] = touser
data["mp_appid"] = mp_appid
data["temp_id"] = temp_id
data["url"] = url
data["mini_program"] = mini_program
data["data"] = data
data := UniformMessageReq{}
data.SiteId = site_id
data.Dbname = dbname
data.Appid = appid
data.Secret = secret
data.Touser = touser
data.MpAppid = mp_appid
data.TemplateId = temp_id
data.Url = redirect_url
data.MiniProgram = mini_program
data.Data = data
data_json, err := json.Marshal(data) data_json, err := json.Marshal(data)
if err != nil { if err != nil {


Loading…
Cancel
Save