- update wechatopen

- update wechatpayopen
master v1.0.106
李光春 1 year ago
parent 140400064b
commit 66c86f0fd3

@ -1,3 +1,8 @@
## v1.0.106
- update [wechatopen](service%2Fwechatopen)
- update [wechatpayopen](service%2Fwechatpayopen)
## v1.0.105
- update [wechatopen](service%2Fwechatopen)

@ -1,5 +1,5 @@
package go_library
func Version() string {
return "1.0.105"
return "1.0.6"
}

@ -8,15 +8,15 @@ import (
)
type DataCubeGetWeAnAlySisAppidDailyRetainInfoResponse struct {
RefDate string `json:"ref_date"`
RefDate string `json:"ref_date"` // 日期
VisitUvNew []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv_new"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv_new"` // 新增用户留存
VisitUv []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv"` // 活跃用户留存
}
type DataCubeGetWeAnAlySisAppidDailyRetainInfoResult struct {

@ -9,11 +9,11 @@ import (
type DataCubeGetWeAnAlySisAppidDailySummaryTrendResponse struct {
List []struct {
RefDate string `json:"ref_date"`
VisitTotal int `json:"visit_total"`
SharePv int `json:"share_pv"`
ShareUv int `json:"share_uv"`
} `json:"list"`
RefDate string `json:"ref_date"` // 日期
VisitTotal int64 `json:"visit_total"` // 累计用户数
SharePv int64 `json:"share_pv"` // 转发次数
ShareUv int64 `json:"share_uv"` // 转发人数
} `json:"list"` // 数据列表
}
type DataCubeGetWeAnAlySisAppidDailySummaryTrendResult struct {

@ -9,15 +9,15 @@ import (
type DataCubeGetWeAnAlySisAppidDailyVisitTrendResponse struct {
List []struct {
RefDate string `json:"ref_date"`
SessionCnt int `json:"session_cnt"`
VisitPv int `json:"visit_pv"`
VisitUv int `json:"visit_uv"`
VisitUvNew int `json:"visit_uv_new"`
StayTimeUv float64 `json:"stay_time_uv"`
StayTimeSession float64 `json:"stay_time_session"`
VisitDepth float64 `json:"visit_depth"`
} `json:"list"`
RefDate string `json:"ref_date"` // 时间
SessionCnt int64 `json:"session_cnt"` // 打开次数(自然周内汇总)
VisitPv int64 `json:"visit_pv"` // 访问次数(自然周内汇总)
VisitUv int64 `json:"visit_uv"` // 访问人数(自然周内去重)
VisitUvNew int64 `json:"visit_uv_new"` // 新用户数(自然周内去重)
StayTimeUv float64 `json:"stay_time_uv"` // 人均停留时长 (浮点型,单位:秒)
StayTimeSession float64 `json:"stay_time_session"` // 次均停留时长 (浮点型,单位:秒)
VisitDepth float64 `json:"visit_depth"` // 平均访问深度 (浮点型)
} `json:"list"` // 数据列表
}
type DataCubeGetWeAnAlySisAppidDailyVisitTrendResult struct {

@ -8,15 +8,15 @@ import (
)
type DataCubeGetWeAnAlySisAppidMonthlyRetainInfoResponse struct {
RefDate string `json:"ref_date"`
RefDate string `json:"ref_date"` // 日期
VisitUvNew []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv_new"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv_new"` // 新增用户留存
VisitUv []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv"` // 活跃用户留存
}
type DataCubeGetWeAnAlySisAppidMonthlyRetainInfoResult struct {

@ -9,15 +9,15 @@ import (
type DataCubeGetWeAnAlySisAppidMonthlyVisitTrendResponse struct {
List []struct {
RefDate string `json:"ref_date"`
SessionCnt int `json:"session_cnt"`
VisitPv int `json:"visit_pv"`
VisitUv int `json:"visit_uv"`
VisitUvNew int `json:"visit_uv_new"`
StayTimeUv float64 `json:"stay_time_uv"`
StayTimeSession float64 `json:"stay_time_session"`
VisitDepth float64 `json:"visit_depth"`
} `json:"list"`
RefDate string `json:"ref_date"` // 时间
SessionCnt int64 `json:"session_cnt"` // 打开次数(自然周内汇总)
VisitPv int64 `json:"visit_pv"` // 访问次数(自然周内汇总)
VisitUv int64 `json:"visit_uv"` // 访问人数(自然周内去重)
VisitUvNew int64 `json:"visit_uv_new"` // 新用户数(自然周内去重)
StayTimeUv float64 `json:"stay_time_uv"` // 人均停留时长 (浮点型,单位:秒)
StayTimeSession float64 `json:"stay_time_session"` // 次均停留时长 (浮点型,单位:秒)
VisitDepth float64 `json:"visit_depth"` // 平均访问深度 (浮点型)
} `json:"list"` // 数据列表
}
type DataCubeGetWeAnAlySisAppidMonthlyVisitTrendResult struct {

@ -11,64 +11,64 @@ type DataCubeGetWeAnAlySisAppidUserPortraitResponse struct {
RefDate string `json:"ref_date"` // 时间范围
VisitUvNew struct {
Province []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"province"` // 分布类型
City []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"city"` // 省份
Genders []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"genders"` // 城市
Platforms []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"platforms"` // 性别
Devices []struct {
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"devices"` // 终端类型
Ages []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"ages"` // 年龄
} `json:"visit_uv_new"` // 新用户画像
VisitUv struct {
Province []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"province"` // 分布类型
City []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"city"` // 省份
Genders []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"genders"` // 城市
Platforms []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"platforms"` // 性别
Devices []struct {
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"devices"` // 终端类型
Ages []struct {
Id int `json:"id"`
Id int64 `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Value int64 `json:"value"`
} `json:"ages"` // 年龄
} `json:"visit_uv"` // 活跃用户画像
}

@ -12,8 +12,8 @@ type DataCubeGetWeAnAlysIsAppidVisitDistributionResponse struct {
List []struct {
Index string `json:"index"` // 分布类型。枚举值为access_source_session_cnt访问来源分布、access_staytime_info访问时长分布、access_depth_info访问深度的分布
ItemList []struct {
Key int `json:"key"` // 场景 id定义在各个 index 下不同,具体参见下方表格
Value int `json:"value"` // 该场景 id 访问 pv
Key int64 `json:"key"` // 场景 id定义在各个 index 下不同,具体参见下方表格
Value int64 `json:"value"` // 该场景 id 访问 pv
} `json:"item_list"` // 分布数据列表
} `json:"list"` // 数据列表
}

@ -8,17 +8,17 @@ import (
)
type DataCubeGetWeAnAlySisAppidVisitPageResponse struct {
RefDate string `json:"ref_date"`
RefDate string `json:"ref_date"` // 日期
List []struct {
PagePath string `json:"page_path"`
PageVisitPv int `json:"page_visit_pv"`
PageVisitUv int `json:"page_visit_uv"`
PageStaytimePv float64 `json:"page_staytime_pv"`
EntrypagePv int `json:"entrypage_pv"`
ExitpagePv int `json:"exitpage_pv"`
PageSharePv int `json:"page_share_pv"`
PageShareUv int `json:"page_share_uv"`
} `json:"list"`
PagePath string `json:"page_path"` // 页面路径
PageVisitPv int64 `json:"page_visit_pv"` // 访问次数
PageVisitUv int64 `json:"page_visit_uv"` // 访问人数
PageStaytimePv float64 `json:"page_staytime_pv"` // 次均停留时长
EntrypagePv int64 `json:"entrypage_pv"` // 进入页次数
ExitpagePv int64 `json:"exitpage_pv"` // 退出页次数
PageSharePv int64 `json:"page_share_pv"` // 转发次数
PageShareUv int64 `json:"page_share_uv"` // 转发人数
} `json:"list"` // 数据列表
}
type DataCubeGetWeAnAlySisAppidVisitPageResult struct {

@ -8,15 +8,15 @@ import (
)
type DataCubeGetWeAnAlySisAppidWeeklyRetainInfoResponse struct {
RefDate string `json:"ref_date"`
RefDate string `json:"ref_date"` // 日期
VisitUvNew []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv_new"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv_new"` // 新增用户留存
VisitUv []struct {
Key int `json:"key"`
Value int `json:"value"`
} `json:"visit_uv"`
Key int64 `json:"key"`
Value int64 `json:"value"`
} `json:"visit_uv"` // 活跃用户留存
}
type DataCubeGetWeAnAlySisAppidWeeklyRetainInfoResult struct {

@ -9,15 +9,15 @@ import (
type DataCubeGetWeAnAlySisAppidWeeklyVisitTrendResponse struct {
List []struct {
RefDate string `json:"ref_date"`
SessionCnt int `json:"session_cnt"`
VisitPv int `json:"visit_pv"`
VisitUv int `json:"visit_uv"`
VisitUvNew int `json:"visit_uv_new"`
StayTimeUv float64 `json:"stay_time_uv"`
StayTimeSession float64 `json:"stay_time_session"`
VisitDepth float64 `json:"visit_depth"`
} `json:"list"`
RefDate string `json:"ref_date"` // 时间
SessionCnt int64 `json:"session_cnt"` // 打开次数(自然周内汇总)
VisitPv int64 `json:"visit_pv"` // 访问次数(自然周内汇总)
VisitUv int64 `json:"visit_uv"` // 访问人数(自然周内去重)
VisitUvNew int64 `json:"visit_uv_new"` // 新用户数(自然周内去重)
StayTimeUv float64 `json:"stay_time_uv"` // 人均停留时长 (浮点型,单位:秒)
StayTimeSession float64 `json:"stay_time_session"` // 次均停留时长 (浮点型,单位:秒)
VisitDepth float64 `json:"visit_depth"` // 平均访问深度 (浮点型)
} `json:"list"` // 数据列表
}
type DataCubeGetWeAnAlySisAppidWeeklyVisitTrendResult struct {

@ -9,10 +9,10 @@ import (
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"github.com/dtapps/go-library/utils/gojson"
"github.com/dtapps/go-library/utils/gorandom"
"net/url"
"time"
@ -63,7 +63,7 @@ func (c *Client) authorization(method string, paramMap map[string]interface{}, r
// 请求报文主体
var signBody string
if len(paramMap) != 0 {
paramJsonBytes, err := json.Marshal(paramMap)
paramJsonBytes, err := gojson.Marshal(paramMap)
if err != nil {
return token, err
}
@ -144,21 +144,3 @@ func (c *Client) getRsa(privateKey []byte) *rsa.PrivateKey {
return key
}
// 通过私钥对字符串以 SHA256WithRSA 算法生成签名信息
func (c *Client) signSHA256WithRSA(source string, privateKey *rsa.PrivateKey) (signature string, err error) {
if privateKey == nil {
return "", fmt.Errorf("private key should not be nil")
}
h := crypto.Hash.New(crypto.SHA256)
_, err = h.Write([]byte(source))
if err != nil {
return "", nil
}
hashed := h.Sum(nil)
signatureByte, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hashed)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(signatureByte), nil
}

@ -0,0 +1,27 @@
package wechatpayopen
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"encoding/base64"
"fmt"
)
// 通过私钥对字符串以 SHA256WithRSA 算法生成签名信息
func (c *Client) signSHA256WithRSA(source string, privateKey *rsa.PrivateKey) (signature string, err error) {
if privateKey == nil {
return "", fmt.Errorf("private key should not be nil")
}
h := crypto.Hash.New(crypto.SHA256)
_, err = h.Write([]byte(source))
if err != nil {
return "", nil
}
hashed := h.Sum(nil)
signatureByte, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hashed)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(signatureByte), nil
}
Loading…
Cancel
Save