Documentation
¶
Overview ¶
普通钉钉用户账号开放相关接口
Index ¶
- Constants
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(plantText []byte) []byte
- func Sign(ticket string, nonceStr string, timeStamp string, url string) string
- type AccessTokenResponse
- type Cache
- type Callback
- type Crypto
- func (c *Crypto) DecryptMsg(signature, timeStamp, nonce, secretStr string) (string, error)
- func (c *Crypto) EncryptMsg(replyMsg, timeStamp, nonce string) (string, string, error)
- func (c *Crypto) GenerateSignature(token, timeStamp, nonce, secretStr string) string
- func (c *Crypto) RandomString(n int, alphabets ...byte) string
- func (c *Crypto) VerifySignature(token, timeStamp, nonce, secretStr, sigture string) bool
- type DataMessage
- type Department
- type DepartmentList
- type DingTalkClient
- func (c *DingTalkClient) CreateChat(name string, owner string, useridlist []string) (string, error)
- func (c *DingTalkClient) CreateFile(size int64) (file FileResponse, err error)
- func (c *DingTalkClient) Decrypt(str string) (string, error)
- func (c *DingTalkClient) DeleteCallback() error
- func (c *DingTalkClient) DepartmentDetail(id int) (Department, error)
- func (c *DingTalkClient) DepartmentList() (DepartmentList, error)
- func (c *DingTalkClient) DownloadMedia(mediaID string, write io.Writer) error
- func (c *DingTalkClient) Encrypt(str string) (string, error)
- func (c *DingTalkClient) GetConfig(nonceStr string, timestamp string, url string) string
- func (c *DingTalkClient) GetJsAPITicket() (ticket string, err error)
- func (c *DingTalkClient) GetSnsPersistentCode(tmpAuthCode string) (string, string, string, error)
- func (c *DingTalkClient) GetSnsToken(openid, persistentCode string) (string, error)
- func (c *DingTalkClient) GetSnsUserInfo(snsToken string) (SnsUserInfoResponse, error)
- func (c *DingTalkClient) ListCallback() (Callback, error)
- func (c *DingTalkClient) RefreshAccessToken() error
- func (c *DingTalkClient) RefreshSnsAccessToken() error
- func (c *DingTalkClient) RegisterCallback(callbacks []string, token string, aes_key string, callbackURL string) error
- func (c *DingTalkClient) SendAppLinkMessage(agentID, touser string, title, text string, picUrl, url string) error
- func (c *DingTalkClient) SendAppMessage(agentID string, touser string, msg string) error
- func (c *DingTalkClient) SendAppOAMessage(agentID string, touser string, msg OAMessage) error
- func (c *DingTalkClient) SendFileMessage(sender string, cid string, mediaID string) error
- func (c *DingTalkClient) SendImageMessage(sender string, cid string, mediaID string) error
- func (c *DingTalkClient) SendLinkMessage(sender string, cid string, mediaID string, url string, title string, ...) error
- func (c *DingTalkClient) SendOAMessage(sender string, cid string, msg OAMessage) error
- func (c *DingTalkClient) SendRobotTextMessage(accessToken string, msg string) error
- func (c *DingTalkClient) SendTextMessage(sender string, cid string, msg string) error
- func (c *DingTalkClient) SendVoiceMessage(sender string, cid string, mediaID string, duration string) error
- func (c *DingTalkClient) UpdateCallback(callbacks []string, token string, aes_key string, callbackURL string) error
- func (c *DingTalkClient) UploadMedia(mediaType string, filename string, reader io.Reader) (media MediaResponse, err error)
- func (c *DingTalkClient) UserInfoByCode(code string) (User, error)
- func (c *DingTalkClient) UserList(departmentID int) (UserList, error)
- func (c *DingTalkClient) UseridByUnionId(unionid string) (string, error)
- type DownloadFile
- type Expirable
- type FileCache
- type FileResponse
- type InMemoryCache
- type JsAPITicketResponse
- type MediaResponse
- type OAMessage
- type OAMessageForm
- type OAMessageRich
- type OAPIResponse
- type SnsPersistentCodeResponse
- type SnsTokenResponse
- type SnsUserInfoResponse
- type Unmarshallable
- type UploadFile
- type User
- type UserList
Constants ¶
const ( //VERSION is SDK version VERSION = "0.1" //ROOT is the root url ROOT = "https://oapi.dingtalk.com/" )
const (
AES_ENCODE_KEY_LENGTH = 43
)
Variables ¶
This section is empty.
Functions ¶
func PKCS7Padding ¶
func PKCS7UnPadding ¶
Types ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct { OAPIResponse AccessToken string `json:"access_token"` Expires int `json:"expires_in"` Created int64 }
AccessTokenResponse is
func (*AccessTokenResponse) CreatedAt ¶
func (e *AccessTokenResponse) CreatedAt() int64
CreatedAt is when the access token is generated
func (*AccessTokenResponse) ExpiresIn ¶
func (e *AccessTokenResponse) ExpiresIn() int
ExpiresIn is how soon the access token is expired
type Callback ¶
type Callback struct { OAPIResponse Token string AES_KEY string `json:"aes_key"` URL string Callbacks []string `json:"call_back_tag"` }
type Crypto ¶
type Crypto struct { Token string AesKey string SuiteKey string // contains filtered or unexported fields }
var DefaultDingtalkCrypto *Crypto
func NewCrypto ¶
token 数据签名需要用到的token,ISV(服务提供商)推荐使用注册套件时填写的token,普通企业可以随机填写 aesKey 数据加密密钥。用于回调数据的加密,长度固定为43个字符,从a-z, A-Z, 0-9共62个字符中选取,您可以随机生成,ISV(服务提供商)推荐使用注册套件时填写的EncodingAESKey suiteKey 一般使用corpID
func (*Crypto) DecryptMsg ¶
signature: 签名字符串 timeStamp: 时间戳 nonce: 随机字符串 secretStr: 密文 返回: 解密后的明文
func (*Crypto) EncryptMsg ¶
replyMsg: 明文字符串 timeStamp: 时间戳 nonce: 随机字符串 返回: 密文,签名字符串
func (*Crypto) GenerateSignature ¶
数据签名
func (*Crypto) VerifySignature ¶
校验数据签名
type Department ¶
type DepartmentList ¶
type DepartmentList struct { OAPIResponse Departments []Department `json:"department"` }
type DingTalkClient ¶
type DingTalkClient struct { CorpID string CorpSecret string AgentID string AccessToken string HTTPClient *http.Client Cache Cache //社交相关的属性 SnsAppID string SnsAppSecret string SnsAccessToken string }
DingTalkClient is the Client to access DingTalk Open API
func NewDingTalkClient ¶
func NewDingTalkClient(corpID string, corpSecret string) *DingTalkClient
NewDingTalkClient creates a DingTalkClient instance
func (*DingTalkClient) CreateChat ¶
CreateChat is
func (*DingTalkClient) CreateFile ¶
func (c *DingTalkClient) CreateFile(size int64) (file FileResponse, err error)
CreateFile is to create a new file in Ding Space
func (*DingTalkClient) Decrypt ¶
func (c *DingTalkClient) Decrypt(str string) (string, error)
Decrypt is 服务端解密
func (*DingTalkClient) DeleteCallback ¶
func (c *DingTalkClient) DeleteCallback() error
DeleteCallback is 删除事件回调接口
func (*DingTalkClient) DepartmentDetail ¶
func (c *DingTalkClient) DepartmentDetail(id int) (Department, error)
DepartmentDetail is 获取部门详情
func (*DingTalkClient) DepartmentList ¶
func (c *DingTalkClient) DepartmentList() (DepartmentList, error)
DepartmentList is 获取部门列表
func (*DingTalkClient) DownloadMedia ¶
func (c *DingTalkClient) DownloadMedia(mediaID string, write io.Writer) error
DownloadMedia is to download a media file from DingTalk
func (*DingTalkClient) Encrypt ¶
func (c *DingTalkClient) Encrypt(str string) (string, error)
Encrypt is 服务端加密
func (*DingTalkClient) GetConfig ¶
func (c *DingTalkClient) GetConfig(nonceStr string, timestamp string, url string) string
GetConfig is to return config in json
func (*DingTalkClient) GetJsAPITicket ¶
func (c *DingTalkClient) GetJsAPITicket() (ticket string, err error)
GetJsAPITicket is to get a valid ticket for JS API
func (*DingTalkClient) GetSnsPersistentCode ¶
获取用户授权的持久授权码
func (*DingTalkClient) GetSnsToken ¶
func (c *DingTalkClient) GetSnsToken(openid, persistentCode string) (string, error)
获取用户授权的SNS_TOKEN
func (*DingTalkClient) GetSnsUserInfo ¶
func (c *DingTalkClient) GetSnsUserInfo(snsToken string) (SnsUserInfoResponse, error)
获取用户授权的个人信息
func (*DingTalkClient) ListCallback ¶
func (c *DingTalkClient) ListCallback() (Callback, error)
ListCallback is 查询事件回调接口
func (*DingTalkClient) RefreshAccessToken ¶
func (c *DingTalkClient) RefreshAccessToken() error
RefreshAccessToken is to get a valid access token
func (*DingTalkClient) RefreshSnsAccessToken ¶
func (c *DingTalkClient) RefreshSnsAccessToken() error
获取钉钉开放应用ACCESS_TOKEN TODO:
根据和赤司(钉钉开发者)的沟通,ACCESS_TOKEN只有两个小时的有效期 但是目前接口貌似没有返回过期时间相关的信息,因此所有相关的调用都需要强制刷新
func (*DingTalkClient) RegisterCallback ¶
func (c *DingTalkClient) RegisterCallback(callbacks []string, token string, aes_key string, callbackURL string) error
RegisterCallback is 注册事件回调接口
func (*DingTalkClient) SendAppLinkMessage ¶
func (c *DingTalkClient) SendAppLinkMessage(agentID, touser string, title, text string, picUrl, url string) error
SendAppLinkMessage is 发送企业会话链接消息
func (*DingTalkClient) SendAppMessage ¶
func (c *DingTalkClient) SendAppMessage(agentID string, touser string, msg string) error
SendAppMessage is 发送企业会话消息
func (*DingTalkClient) SendAppOAMessage ¶
func (c *DingTalkClient) SendAppOAMessage(agentID string, touser string, msg OAMessage) error
SendAppOAMessage is 发送OA消息
func (*DingTalkClient) SendFileMessage ¶
func (c *DingTalkClient) SendFileMessage(sender string, cid string, mediaID string) error
SendFileMessage is 发送文件消息
func (*DingTalkClient) SendImageMessage ¶
func (c *DingTalkClient) SendImageMessage(sender string, cid string, mediaID string) error
SendImageMessage is 发送图片消息
func (*DingTalkClient) SendLinkMessage ¶
func (c *DingTalkClient) SendLinkMessage(sender string, cid string, mediaID string, url string, title string, text string) error
SendLinkMessage is 发送链接消息
func (*DingTalkClient) SendOAMessage ¶
func (c *DingTalkClient) SendOAMessage(sender string, cid string, msg OAMessage) error
SendOAMessage is 发送OA消息
func (*DingTalkClient) SendRobotTextMessage ¶
func (c *DingTalkClient) SendRobotTextMessage(accessToken string, msg string) error
SendRobotTextMessage can send a text message to a group chat
func (*DingTalkClient) SendTextMessage ¶
func (c *DingTalkClient) SendTextMessage(sender string, cid string, msg string) error
SendTextMessage is 发送普通文本消息
func (*DingTalkClient) SendVoiceMessage ¶
func (c *DingTalkClient) SendVoiceMessage(sender string, cid string, mediaID string, duration string) error
SendVoiceMessage is 发送语音消息
func (*DingTalkClient) UpdateCallback ¶
func (c *DingTalkClient) UpdateCallback(callbacks []string, token string, aes_key string, callbackURL string) error
UpdateCallback is 更新事件回调接口
func (*DingTalkClient) UploadMedia ¶
func (c *DingTalkClient) UploadMedia(mediaType string, filename string, reader io.Reader) (media MediaResponse, err error)
UploadMedia is to upload media file to DingTalk
func (*DingTalkClient) UserInfoByCode ¶
func (c *DingTalkClient) UserInfoByCode(code string) (User, error)
UserInfoByCode 校验免登录码并换取用户身份
func (*DingTalkClient) UserList ¶
func (c *DingTalkClient) UserList(departmentID int) (UserList, error)
UserList is 获取部门成员
func (*DingTalkClient) UseridByUnionId ¶
func (c *DingTalkClient) UseridByUnionId(unionid string) (string, error)
UseridByUnionId 通过UnionId获取玩家Userid
type DownloadFile ¶
DownloadFile is for downloading a single file from DingTalk
type FileResponse ¶
type FileResponse struct { OAPIResponse Code int Msg string UploadID string `json:"uploadid"` Writer io.Writer }
FileResponse is
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
func NewInMemoryCache ¶
func NewInMemoryCache() *InMemoryCache
func (*InMemoryCache) Get ¶
func (c *InMemoryCache) Get(data Expirable) error
func (*InMemoryCache) Set ¶
func (c *InMemoryCache) Set(data Expirable) error
type JsAPITicketResponse ¶
type JsAPITicketResponse struct { OAPIResponse Ticket string Expires int `json:"expires_in"` Created int64 }
JsAPITicketResponse is
func (*JsAPITicketResponse) CreatedAt ¶
func (e *JsAPITicketResponse) CreatedAt() int64
CreatedAt is when the ticket is generated
func (*JsAPITicketResponse) ExpiresIn ¶
func (e *JsAPITicketResponse) ExpiresIn() int
ExpiresIn is how soon the ticket is expired
type MediaResponse ¶
type MediaResponse struct { OAPIResponse Type string MediaID string `json:"media_id"` Writer io.Writer }
MediaResponse is
type OAMessage ¶
type OAMessage struct { URL string `json:"message_url"` PcURL string `json:"pc_message_url"` Head struct { BgColor string `json:"bgcolor,omitempty"` Text string `json:"text,omitempty"` } `json:"head,omitempty"` Body struct { Title string `json:"title,omitempty"` Form []OAMessageForm `json:"form,omitempty"` Rich OAMessageRich `json:"rich,omitempty"` Content string `json:"content,omitempty"` Image string `json:"image,omitempty"` FileCount int `json:"file_count,omitempty"` Author string `json:"author,omitempty"` } `json:"body,omitempty"` }
OAMessage is the Message for OA
func (*OAMessage) AppendFormItem ¶
type OAMessageForm ¶
type OAMessageRich ¶
type OAPIResponse ¶
OAPIResponse is
type SnsPersistentCodeResponse ¶
type SnsPersistentCodeResponse struct { OAPIResponse UnionID string `json:"unionid"` OpenID string `json:"openid"` PersistentCode string `json:"persistent_code"` }
获取用户授权的持久授权码返回信息
type SnsTokenResponse ¶
type SnsTokenResponse struct { OAPIResponse Expires int `json:"expires_in"` SnsToken string `json:"sns_token"` }
type SnsUserInfoResponse ¶
type SnsUserInfoResponse struct { OAPIResponse CorpInfo []struct { CorpName string `json:"corp_name"` IsAuth bool `json:"is_auth"` IsManager bool `json:"is_manager"` RightsLevel int `json:"rights_level"` } `json:"corp_info"` UserInfo struct { MaskedMobile string `json:"marskedMobile"` Nick string `json:"nick"` OpenID string `json:"openid"` UnionID string `json:"unionid"` DingID string `json:"dingId"` } `json:"user_info"` }
type Unmarshallable ¶
type Unmarshallable interface {
// contains filtered or unexported methods
}
Unmarshallable is
type UploadFile ¶
UploadFile is for uploading a single file to DingTalk
type UserList ¶
type UserList struct { OAPIResponse HasMore bool Userlist []User }