dkf

package
v0.0.0-...-7011273 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

多客服接口.

Index

Constants

View Source
const (
	OnlineKfInfoStatusPC          = 1
	OnlineKfInfoStatusMobile      = 2
	OnlineKfInfoStatusPCAndMobile = 3
)
View Source
const (
	RecordPageSizeLimit = 1000 // 客户聊天记录每页最多拉取1000条
)

Variables

View Source
var ErrNoHeadImage = errors.New("没有头像")

Functions

This section is empty.

Types

type Client

type Client struct {
	*mp.WechatClient
}

func NewClient

func NewClient(AccessTokenServer mp.AccessTokenServer, httpClient *http.Client) Client

兼容保留, 建議實際項目全局維護一個 *mp.WechatClient

func (Client) AddKfAccount

func (clt Client) AddKfAccount(account, nickname, password string, isPwdPlain bool) (err error)

添加客服账号.

account:    完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符。
nickname:   客服昵称,最长6个汉字或12个英文字符
password:   客服账号登录密码
isPwdPlain: 标识 password 是否为明文格式, true 表示是明文密码, false 表示是密文密码.

func (Client) DeleteKfAccount

func (clt Client) DeleteKfAccount(kfAccount string) (err error)

删除客服账号

func (Client) GetRecord

func (clt Client) GetRecord(request *GetRecordRequest) (recordList []Record, err error)

获取客服聊天记录

func (Client) KfList

func (clt Client) KfList() (KfList []KfInfo, err error)

获取客服基本信息.

func (Client) OnlineKfList

func (clt Client) OnlineKfList() (KfList []OnlineKfInfo, err error)

获取在线客服接待信息.

func (Client) RecordIterator

func (clt Client) RecordIterator(request *GetRecordRequest) (iter *RecordIterator, err error)

获取聊天记录遍历器.

func (Client) SetKfAccount

func (clt Client) SetKfAccount(account, nickname, password string, isPwdPlain bool) (err error)

设置客服信息

account:    完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符。
nickname:   客服昵称,最长6个汉字或12个英文字符
password:   客服账号登录密码
isPwdPlain: 标识 password 是否为明文格式, true 表示是明文密码, false 表示是密文密码.

func (Client) UploadKfHeadImage

func (clt Client) UploadKfHeadImage(kfAccount, imagePath string) (err error)

上传客服头像.

开发者可调用本接口来上传图片作为客服人员的头像,头像图片文件必须是jpg格式,推荐使用640*640大小的图片以达到最佳效果。

func (Client) UploadKfHeadImageFromReader

func (clt Client) UploadKfHeadImageFromReader(kfAccount, filename string, reader io.Reader) (err error)

上传客服头像.

开发者可调用本接口来上传图片作为客服人员的头像,头像图片文件必须是jpg格式,推荐使用640*640大小的图片以达到最佳效果。
注意参数 filename 不是文件路径, 是指定 multipart/form-data 里面文件名称

type GetRecordRequest

type GetRecordRequest struct {
	StartTime int64  `json:"starttime"` // 查询开始时间,UNIX时间戳
	EndTime   int64  `json:"endtime"`   // 查询结束时间,UNIX时间戳,每次查询不能跨日查询
	OpenId    string `json:"openid"`    // 普通用户的标识,对当前公众号唯一
	PageSize  int    `json:"pagesize"`  // 每页大小,每页最多拉取1000条
	PageIndex int    `json:"pageindex"` // 查询第几页,从1开始
}

获取客服聊天记录 请求消息结构

type KfInfo

type KfInfo struct {
	Id           string `json:"kf_id,string"` // 客服工号
	Account      string `json:"kf_account"`   // 完整客服账号,格式为:账号前缀@公众号微信号
	Nickname     string `json:"kf_nick"`      // 客服昵称
	HeadImageURL string `json:"kf_headimg"`   // 客服头像
}

客服基本信息

func (*KfInfo) HeadImageSize

func (info *KfInfo) HeadImageSize() (size int, err error)

获取客服图像的大小, 如果客服没有图像则返回 ErrNoHeadImage 错误.

type OnlineKfInfo

type OnlineKfInfo struct {
	Id                  string `json:"kf_id,string"`  // 客服工号
	Account             string `json:"kf_account"`    // 完整客服账号,格式为:账号前缀@公众号微信号
	Status              int    `json:"status"`        // 客服在线状态 1:pc在线,2:手机在线。若pc和手机同时在线则为 1+2=3
	AutoAcceptThreshold int    `json:"auto_accept"`   // 客服设置的最大自动接入数
	AcceptingNumber     int    `json:"accepted_case"` // 客服当前正在接待的会话数
}

在线客服接待信息

type Record

type Record struct {
	Worker string `json:"worker"` // 客服账号
	OpenId string `json:"openid"` // 用户的标识,对当前公众号唯一

	// 操作ID(会话状态):
	// 1000	 创建未接入会话
	// 1001	 接入会话
	// 1002	 主动发起会话
	// 1004	 关闭会话
	// 1005	 抢接会话
	// 2001	 公众号收到消息
	// 2002	 客服发送消息
	// 2003	 客服收到消息
	OperCode  int    `json:"opercode"`
	Timestamp int64  `json:"time"` // 操作时间,UNIX时间戳
	Text      string `json:"text"` // 聊天记录
}

一条聊天记录

type RecordIterator

type RecordIterator struct {
	// contains filtered or unexported fields
}

聊天记录遍历器.

iter, err := Client.RecordIterator(request)
if err != nil {
    // TODO: 增加你的代码
}

for iter.HasNext() {
    records, err := iter.NextPage()
    if err != nil {
        // TODO: 增加你的代码
    }
    // TODO: 增加你的代码
}

func (*RecordIterator) HasNext

func (iter *RecordIterator) HasNext() bool

func (*RecordIterator) NextPage

func (iter *RecordIterator) NextPage() (records []Record, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL