Documentation
¶
Index ¶
- Constants
- func BoolPtr(b bool) *bool
- func Debug(msg interface{})
- func DeleteUrlContent(urlStr string, strJson string, headers map[string]string) (string, error)
- func GetDepartmentListTree(accessToken string, deptId int, language string) ([]DepartmentSimpleTree, DingTalkApiErr3Dto)
- func GetLoginUrl(redirectUri, clientId, scope, state string) string
- func GetUrlContent(urlStr string, headers map[string]string) (string, error)
- func JsonUnmarshal(str string, obj interface{}) error
- func PostUrlContnet4json(urlStr string, strJson string, headers map[string]string) (string, error)
- func PutUrlContent(urlStr string, strJson string, headers map[string]string) (string, error)
- func StringPtr(s string) *string
- func ToJson(v interface{}) string
- type AccessTokenRespDto
- type DepartmentListRespDto
- type DepartmentReqDto
- type DepartmentSimpleInfo
- type DepartmentSimpleTree
- type DeptUseridDto
- type DeptUseridListRespDto
- type DingAgentConfig
- type DingCorpConfig
- type DingTalkApiErr2Dto
- type DingTalkApiErr3Dto
- type DingTalkApiErrDto
- type GetUseridByMobileReqDto
- type GetUseridByMobileRespDto
- type RequestIdDto
- type UserAccessTokenReqDto
- type UserAccessTokenRespDto
- type UserInfoRespDto
- type UserProfileDto
- type UserProfileRespDto
- type UseridByMobileResultDto
Constants ¶
View Source
const ( ScopeOpenid = "openid" ScopeOpenIdCropid = "openid corpid" LoginUrl = "%s/oauth2/auth?redirect_uri=%s&response_type=code&client_id=%s&scope=%s&state=%s&prompt=consent" UserAccessTokenUrl = "%s/v1.0/oauth2/userAccessToken" UserInfo4UserAccessTokenUrl = "%s/v1.0/contact/users/me" // 企业内部应用获取access_token GetAccessTokenUrl = "%s/gettoken?appkey=%s&appsecret=%s" // 部门列表 DepartmentUrl = "%s/topapi/v2/department/listsub?access_token=%s" // 获取指定部门的userid列表 DepartmentUseridListUrl = "%s/topapi/user/listid?access_token=%s" // 获取指定用户的详细信息 UserInfoUrl = "%s/topapi/v2/user/get?access_token=%s" // 发送工作通知 WorkNotifyMsgUrl = "%s/topapi/message/corpconversation/asyncsend_v2?access_token=%s" // 撤回工作消息 RecallWorkNotifyMsgUrl = "%s/topapi/message/corpconversation/recall?access_token=%s" // 根据手机号获取企业账号用户的userId GetUseridByMobileUrl = "%s/topapi/v2/user/getbymobile?access_token=%s" // 创建钉钉待办任务 ?operatorId= CreateTodoTaskUrl = "%s/v1.0/todo/users/%s/tasks%s" // 删除钉钉待办任务 ?operatorId= DeleteTodoTaskUrl = "%s/v1.0/todo/users/%s/tasks/%s%s" // 查询企业下用户待办列表 GetTodoTaskUrl = "%s/v1.0/todo/users/%s/org/tasks/query" // 更新待办任务状态 /v1.0/todo/users/{unionId}/tasks/{taskId}/executorStatus?operatorId= UpdateTodoTaskStatusUrl = "%s/v1.0/todo/users/%s/tasks/%s/executorStatus%s" // 更新待办任务信息 /v1.0/todo/users/{unionId}/tasks/{taskId}?operatorId= UpdateTodoTaskInfoUrl = "%s/v1.0/todo/users/%s/tasks/%s%s" )
View Source
const ( // 新版api域名 DingApiDomain = "https://api.dingtalk.com" // 旧版api域名 DingOapiDomain = "https://oapi.dingtalk.com" DingLoginDomain = "https://login.dingtalk.com" )
Variables ¶
This section is empty.
Functions ¶
func DeleteUrlContent ¶
func GetDepartmentListTree ¶
func GetDepartmentListTree(accessToken string, deptId int, language string) ([]DepartmentSimpleTree, DingTalkApiErr3Dto)
func GetLoginUrl ¶
GetLoginUrl 第1步: 拼接钉钉登录地址: https://open.dingtalk.com/document/isvapp-server/obtain-identity-credentials
func JsonUnmarshal ¶
func PostUrlContnet4json ¶
func PutUrlContent ¶
Types ¶
type AccessTokenRespDto ¶
type AccessTokenRespDto struct {
DingTalkApiErr2Dto
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
func GetAccessToken ¶
func GetAccessToken(cfg DingAgentConfig) AccessTokenRespDto
企业内部应用获取access_token
type DepartmentListRespDto ¶
type DepartmentListRespDto struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
RequestID string `json:"request_id"`
Result []DepartmentSimpleInfo `json:"result"`
}
func GetDepartmentList ¶
func GetDepartmentList(accessToken string, deptId int, language string) DepartmentListRespDto
获取部门列表:只支持获取当前部门的下一级部门基础信息,不支持获取当前部门下所有层级子部门
type DepartmentReqDto ¶
type DepartmentSimpleInfo ¶
type DepartmentSimpleTree ¶
type DepartmentSimpleTree struct {
AutoAddUser bool `json:"auto_add_user"` // 新人是否自动加入该群,true是,false否
CreateDeptGroup bool `json:"create_dept_group"` //是否同步创建一个关联此部门的企业群,true是,false否
DeptID int `json:"dept_id"` //部门ID
Name string `json:"name"` //部门名称
ParentID int `json:"parent_id"` //上级部门
SubDeptList []DepartmentSimpleTree `json:"sub_dept_list"` // 子部门
}
部门树
type DeptUseridDto ¶
type DeptUseridDto struct {
UseridList []string `json:"userid_list"`
}
type DeptUseridListRespDto ¶
type DeptUseridListRespDto struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
RequestID string `json:"request_id"`
Result DeptUseridDto `json:"result"`
}
func GetDepartmentUseridList ¶
func GetDepartmentUseridList(accessToken string, deptId int) DeptUseridListRespDto
获取指定部门的userid列表
type DingAgentConfig ¶
type DingAgentConfig struct {
AgentId string
AppKey string
AppSecret string
AesKey string
Token string
}
应用配置
type DingTalkApiErr2Dto ¶
type DingTalkApiErr3Dto ¶
type DingTalkApiErrDto ¶
type GetUseridByMobileReqDto ¶
type GetUseridByMobileRespDto ¶
type GetUseridByMobileRespDto struct {
DingTalkApiErr2Dto
Result UseridByMobileResultDto `json:"result"`
RequestID string `json:"request_id"`
}
func GetUseridByMobile ¶
func GetUseridByMobile(w GetUseridByMobileReqDto, at string) GetUseridByMobileRespDto
根据手机号获取企业账号用户的userId:https://open.dingtalk.com/document/orgapp/query-users-by-phone-number
type RequestIdDto ¶
type RequestIdDto struct {
RequestId string `json:"request_id"`
}
type UserAccessTokenReqDto ¶
type UserAccessTokenRespDto ¶
type UserAccessTokenRespDto struct {
DingTalkApiErrDto
ExpireIn int `json:"expireIn"`
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
CorpId string `json:"corpId"` //所选企业corpId
}
func GetUserAccessToken4authCode ¶
func GetUserAccessToken4authCode(authCode string, dingCfg DingAgentConfig) UserAccessTokenRespDto
第2步: 通过用户授权成功后的authCode获取访问令牌
func RefreshToken ¶
func RefreshToken(refreshToken string, dingCfg DingAgentConfig) UserAccessTokenRespDto
刷新访问令牌
type UserInfoRespDto ¶
type UserInfoRespDto struct {
DingTalkApiErrDto
Nick string `json:"nick"` // 昵称
UnionID string `json:"unionId"`
OpenID string `json:"openId"`
Email string `json:"email"`
AvatarUrl string `json:"avatarUrl"` // 头像地址
Mobile string `json:"mobile"` // 手机号
StateCode string `json:"stateCode"` // 手机号对应的国家号
}
func GetUserInfo4UserAccessToken ¶
func GetUserInfo4UserAccessToken(userAccessToken string) UserInfoRespDto
第3步: 获取用户信息:https://open.dingtalk.com/document/isvapp-server/dingtalk-retrieve-user-information
type UserProfileDto ¶
type UserProfileDto struct {
Active bool `json:"active"`
Admin bool `json:"admin"`
Avatar string `json:"avatar"`
Boss bool `json:"boss"`
DeptIDList []int `json:"dept_id_list"`
DeptOrderList []struct {
DeptID int `json:"dept_id"`
Order int64 `json:"order"`
} `json:"dept_order_list"`
ExclusiveAccount bool `json:"exclusive_account"`
HideMobile bool `json:"hide_mobile"`
LeaderInDept []struct {
DeptID int `json:"dept_id"`
Leader bool `json:"leader"`
} `json:"leader_in_dept"`
Mobile string `json:"mobile"`
Name string `json:"name"`
RealAuthed bool `json:"real_authed"`
RoleList []struct {
GroupName string `json:"group_name"`
ID int `json:"id"`
Name string `json:"name"`
} `json:"role_list"`
Senior bool `json:"senior"`
StateCode string `json:"state_code"`
Unionid string `json:"unionid"`
Userid string `json:"userid"`
}
type UserProfileRespDto ¶
type UserProfileRespDto struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
RequestID string `json:"request_id"`
Result UserProfileDto `json:"result"`
}
func GetUserInfo ¶
func GetUserInfo(accessToken string, userid string, lang string) UserProfileRespDto
获取指定用户的详细信息
type UseridByMobileResultDto ¶
type UseridByMobileResultDto struct {
ExclusiveAccountUseridList []interface{} `json:"exclusive_account_userid_list"`
Userid string `json:"userid"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.