aa
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package qywxapi
|
||||
|
||||
import "encoding/json"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func (a *API) GetProviderToken() (token string, err error) {
|
||||
params := map[string]interface{}{
|
||||
@@ -14,3 +18,71 @@ func (a *API) GetProviderToken() (token string, err error) {
|
||||
}
|
||||
return token, err
|
||||
}
|
||||
|
||||
func (a *API) GetToken() (token string, err error) {
|
||||
result, err := a.AccessAPI(fmt.Sprintf("cgi-bin/gettoken?corpid=%s&corpsecret=%s", a.appID, a.secret), "", false)
|
||||
if result["access_token"] != "" {
|
||||
return result["access_token"].(string), err
|
||||
}
|
||||
return token, err
|
||||
}
|
||||
|
||||
type GroupchatListResult struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
GroupChatList []struct {
|
||||
ChatID string `json:"chat_id"`
|
||||
Status int `json:"status"`
|
||||
} `json:"group_chat_list"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
//获取客户群列表
|
||||
func (a *API) GroupchatList(cursor string, limit int) (groupchatListResult *GroupchatListResult, err error) {
|
||||
params := map[string]interface{}{
|
||||
"limit": limit,
|
||||
"cursor": cursor,
|
||||
}
|
||||
str, _ := json.Marshal(params)
|
||||
result, err := a.AccessAPI(fmt.Sprintf("cgi-bin/externalcontact/groupchat/list?access_token=%s", a.token), string(str), true)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result, &groupchatListResult, false)
|
||||
}
|
||||
return groupchatListResult, err
|
||||
}
|
||||
|
||||
type GroupchatResutl struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
GroupChat struct {
|
||||
ChatID string `json:"chat_id"`
|
||||
Name string `json:"name"`
|
||||
Owner string `json:"owner"`
|
||||
CreateTime int `json:"create_time"`
|
||||
MemberList []struct {
|
||||
Userid string `json:"userid"`
|
||||
Type int `json:"type"`
|
||||
JoinTime int `json:"join_time"`
|
||||
JoinScene int `json:"join_scene"`
|
||||
UnionID string `json:"unionid"`
|
||||
Invitor struct {
|
||||
Userid string `json:"userid"`
|
||||
} `json:"invitor,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
} `json:"member_list"`
|
||||
AdminList []interface{} `json:"admin_list"`
|
||||
} `json:"group_chat"`
|
||||
}
|
||||
|
||||
//获取客户群详情
|
||||
func (a *API) Groupchat(chat_id string) (groupchatListResult *GroupchatResutl, err error) {
|
||||
params := map[string]interface{}{
|
||||
"chat_id": chat_id,
|
||||
}
|
||||
str, _ := json.Marshal(params)
|
||||
result, err := a.AccessAPI(fmt.Sprintf("cgi-bin/externalcontact/groupchat/get?access_token=%s", a.token), string(str), true)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result, &groupchatListResult, false)
|
||||
}
|
||||
return groupchatListResult, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user