You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
2 years ago
|
package wechatoffice
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
2 years ago
|
"go.dtapp.net/library/gorequest"
|
||
2 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type CgiBinUserGetResponse struct {
|
||
|
Total int `json:"total"`
|
||
|
Count int `json:"count"`
|
||
|
Data struct {
|
||
|
Openid []string `json:"openid"`
|
||
|
} `json:"data"`
|
||
|
NextOpenid string `json:"next_openid"`
|
||
|
}
|
||
|
|
||
|
type CgiBinUserGetResult struct {
|
||
|
Result CgiBinUserGetResponse // 结果
|
||
|
Body []byte // 内容
|
||
2 years ago
|
Http gorequest.Response // 请求
|
||
2 years ago
|
Err error // 错误
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewCgiBinUserGetResult(result CgiBinUserGetResponse, body []byte, http gorequest.Response, err error) *CgiBinUserGetResult {
|
||
|
return &CgiBinUserGetResult{Result: result, Body: body, Http: http, Err: err}
|
||
2 years ago
|
}
|
||
|
|
||
|
// CgiBinUserGet 获取用户列表
|
||
|
// https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html
|
||
|
func (app *App) CgiBinUserGet(nextOpenid string) *CgiBinUserGetResult {
|
||
2 years ago
|
app.accessToken = app.GetAccessToken()
|
||
2 years ago
|
// 请求
|
||
2 years ago
|
request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/user/get?access_token=%s&next_openid=%s", app.accessToken, nextOpenid), map[string]interface{}{}, http.MethodGet)
|
||
2 years ago
|
// 定义
|
||
|
var response CgiBinUserGetResponse
|
||
2 years ago
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewCgiBinUserGetResult(response, request.ResponseBody, request, err)
|
||
2 years ago
|
}
|