service

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Zlib Imports: 10 Imported by: 0

README

服务商

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorpIdToOpenCorpId

func CorpIdToOpenCorpId(api *token.Api) (string, error)

CorpIdToOpenCorpId 明文corpid转换为加密corpid POST(HTTPS) 为更好地保护企业与用户的数据,第三方应用获取的corpid不再是明文的corpid,将升级为第三方服务商级别的加密corpid(了解更多)。第三方可以将已有的明文corpid转换为第三方的加密corpid。 请求地址:https://qyapi.weixin.qq.com/cgi-bin/service/corpid_to_opencorpid?provider_access_token=ACCESS_TOKEN

func GetAppQrCode

func GetAppQrCode(api *token.Api, qr QRCodeReq) (string, error)

GetAppQrCode 获取应用二维码 POST(HTTPS) 用于获取第三方应用二维码。 https://qyapi.weixin.qq.com/cgi-bin/service/get_app_qrcode?suite_access_token=SUITE_ACCESS_TOKEN

func GetCorpToken

func GetCorpToken(corp token.Token, d data.D) (access.Token, error)

GetCorpToken 获取企业凭证 POST(HTTPS) 第三方服务商在取得企业的永久授权码后,通过此接口可以获取到企业的access_token。 获取后可通过通讯录、应用、消息等企业接口来运营这些应用。 此处获得的企业access_token与企业获取access_token拿到的token,本质上是一样的,只不过获取方式不同。 获取之后,就跟普通企业一样使用token调用API接口 https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token?suite_access_token=SUITE_ACCESS_TOKEN

func GetPermanentCode

func GetPermanentCode(corp token.Token, d data.D) (access.Token, error)

GetPermanentCode 获取企业永久授权码 POST(HTTPS)https://qyapi.weixin.qq.com/cgi-bin/service/get_permanent_code

func GetProviderToken

func GetProviderToken(corp token.Token, d data.D) (access.Token, error)

GetProviderToken 获取服务商凭证 开发者需要缓存provider_access_token,用于后续接口的调用(注意:不能频繁调用get_provider_token接口,否则会受到频率拦截)。 当provider_access_token失效或过期时,需要重新获取。 provider_access_token的有效期通过返回的expires_in来传达,正常情况下为7200秒(2小时),有效期内重复获取返回相同结果,过期后获取会返回新的provider_access_token。 provider_access_token至少保留512字节的存储空间。 企业微信可能会出于运营需要,提前使provider_access_token失效,开发者应实现provider_access_token失效时重新获取的逻辑

func GetSuiteToken

func GetSuiteToken(corp token.Token, d data.D) (access.Token, error)

GetSuiteToken 获取第三方应用凭证 ticket suite_ticket 由于第三方服务商可能托管了大量的企业,其安全问题造成的影响会更加严重,故API中除了合法来源IP校验之外,还额外增加了suite_ticket作为安全凭证。 获取suite_access_token时,需要suite_ticket参数。suite_ticket由企业微信后台定时推送给“指令回调URL”,每十分钟更新一次,见推送suite_ticket。 suite_ticket实际有效期为30分钟,可以容错连续两次获取suite_ticket失败的情况,但是请永远使用最新接收到的suite_ticket。 通过本接口获取的suite_access_token有效期为2小时,开发者需要进行缓存,不可频繁获取。

Types

type AdminInfo

type AdminInfo struct {
	Userid     string `json:"userid"`
	OpenUserid string `json:"open_userid"`
	AuthType   int    `json:"auth_type"`
}

type AdminList

type AdminList struct {
	Admins []AdminInfo `json:"admin"`
}

func GetAdminList

func GetAdminList(api *token.Api, authCorpId string, agentId int64) (*AdminList, error)

GetAdminList 获取应用的管理员列表 POST(HTTPS) https://qyapi.weixin.qq.com/cgi-bin/service/get_admin_list?suite_access_token=SUITE_ACCESS_TOKEN

type Agent

type Agent struct {
	AgentId          int        `json:"agentid"`
	Name             string     `json:"name"`
	RoundLogoUrl     string     `json:"round_logo_url"`
	SquareLogoUrl    string     `json:"square_logo_url"`
	Appid            int        `json:"appid"`
	AuthMode         int        `json:"auth_mode,omitempty"`
	IsCustomizedApp  bool       `json:"is_customized_app,omitempty"`
	AuthFromThirdApp bool       `json:"auth_from_thirdapp,omitempty"`
	Privilege        Privilege  `json:"privilege,omitempty"`
	SharedFrom       SharedFrom `json:"shared_from"`
}

type AuthCorpInfo

type AuthCorpInfo struct {
	CorpId            string `json:"corpid"`
	CorpName          string `json:"corp_name"`
	CorpType          string `json:"corp_type"`
	CorpSquareLogoUrl string `json:"corp_square_logo_url"`
	CorpUserMax       int    `json:"corp_user_max"`
	CorpFullName      string `json:"corp_full_name"`
	VerifiedEndTime   int    `json:"verified_end_time"`
	SubjectType       int    `json:"subject_type"`
	CorpWxqrcode      string `json:"corp_wxqrcode"`
	CorpScale         string `json:"corp_scale"`
	CorpIndustry      string `json:"corp_industry"`
	CorpSubIndustry   string `json:"corp_sub_industry"`
}

type AuthInfo

type AuthInfo struct {
	Agent []Agent `json:"agent"`
}

type AuthNotify

type AuthNotify struct {
	HeadNotify        // InfoType = create_auth, change_auth, cancel_auth
	AuthCode   string `json:"AuthCode" xml:"AuthCode"`
	State      string `json:"State" xml:"State"`
}

AuthNotify 授权通知事件

type AuthUserInfo

type AuthUserInfo struct {
	Userid     string `json:"userid"`
	OpenUserid string `json:"open_userid"`
	Name       string `json:"name"`
	Avatar     string `json:"avatar"`
}

type ContactInfo

type ContactInfo struct {
	UserID         string    `json:"UserID" xml:"UserID"`
	OpenUserID     string    `json:"OpenUserID" xml:"OpenUserID"`
	Name           string    `json:"Name" xml:"Name"`
	Department     []string  `json:"Department" xml:"Department"`
	MainDepartment string    `json:"MainDepartment" xml:"MainDepartment"`
	IsLeaderInDept []string  `json:"IsLeaderInDept" xml:"IsLeaderInDept"`
	DirectLeader   []string  `json:"DirectLeader" xml:"DirectLeader"`
	Mobile         string    `json:"Mobile" xml:"Mobile"`
	Position       string    `json:"Position" xml:"Position"`
	Gender         int       `json:"Gender" xml:"Gender"`
	BizMail        string    `json:"BizMail" xml:"BizMail"`
	Email          string    `json:"Email" xml:"Email"`
	Avatar         string    `json:"Avatar" xml:"Avatar"`
	Alias          string    `json:"Alias" xml:"Alias"`
	Telephone      string    `json:"Telephone" xml:"Telephone"`
	ExtAttr        []ExtAttr `json:"ExtAttr" xml:"ExtAttr"`
}

type ContactNotify

type ContactNotify struct {
	HeadNotify // InfoType = change_contact, ChangeType= create_user, update_user,delete_user
	ContactInfo
}

ContactNotify 成员通知事件

type CustomizedAuthUrl

type CustomizedAuthUrl struct {
	QrcodeUrl string `json:"qrcode_url"`
	ExpiresIn int    `json:"expires_in"`
}

func GetCustomizedAuthUrl

func GetCustomizedAuthUrl(api *token.Api, state string, templateId []string) (*CustomizedAuthUrl, error)

GetCustomizedAuthUrl 获取带参授权链接 该API用于获取代开发自建应用授权链接,用于生成带参临时二维码。 请求方式:POST(HTTPS) 请求地址: https://qyapi.weixin.qq.com/cgi-bin/service/get_customized_auth_url?provider_access_token=PROVIDER_ACCESS_TOKEN

type DealerCorpInfo

type DealerCorpInfo struct {
	CorpId   string `json:"corpid"`
	CorpName string `json:"corp_name"`
}

type DepartmentInfo

type DepartmentInfo struct {
	Id       int64  `json:"Id" xml:"Id"`
	Name     string `json:"Name" xml:"Name"`
	ParentId int64  `json:"ParentId" xml:"ParentId"`
	Order    int    `json:"Order" xml:"Order"`
}

type DepartmentNotify

type DepartmentNotify struct {
	HeadNotify // InfoType = change_contact, ChangeType = create_party, update_party,delete_party
	DepartmentInfo
}

DepartmentNotify 部门通知事件

type ExtAttr

type ExtAttr struct {
	Name string `json:"Name" xml:"Name"`
	Type int    `json:"Type" xml:"Type"`
}

type HeadNotify

type HeadNotify struct {
	SuiteId    string `json:"SuiteId" xml:"SuiteId"`
	InfoType   string `json:"InfoType" xml:"InfoType"`
	AuthCorpId string `json:"AuthCorpId" xml:"AuthCorpId"`
	ChangeType string `json:"ChangeType" xml:"ChangeType"` //create_user, update_user,delete_user
	TimeStamp  int64  `json:"TimeStamp" xml:"TimeStamp"`
}

type LoginAgent

type LoginAgent struct {
	Agentid  int `json:"agentid"`
	AuthType int `json:"auth_type"`
}

type LoginAuthInfo

type LoginAuthInfo struct {
	Department []LoginDepartment `json:"department"`
}

type LoginDepartment

type LoginDepartment struct {
	Id       int  `json:"id"`
	Writable bool `json:"writable"`
}

type LoginInfo

type LoginInfo struct {
	Usertype int           `json:"usertype"`
	UserInfo AuthUserInfo  `json:"user_info"`
	CorpInfo AuthCorpInfo  `json:"corp_info"`
	Agent    []LoginAgent  `json:"agent"`
	AuthInfo LoginAuthInfo `json:"auth_info"`
}

func GetLoginInfo

func GetLoginInfo(api *token.Api, authCode string) (*LoginInfo, error)

GetLoginInfo 获取登录用户信息 [扫码授权登录] 第三方可通过如下接口,获取登录用户的信息。建议用户以返回信息中的corpid及userid为主键匹配用户 授权登录服务商的网站时,使用应用提供商的provider_access_token 请求方式:POST(HTTPS) 请求地址: https://qyapi.weixin.qq.com/cgi-bin/service/get_login_info?access_token=PROVIDER_ACCESS_TOKEN

type Permanent

type Permanent struct {
	access.PermanentAccessToken
	PermanentInfo
}

func GetAuthInfo

func GetAuthInfo(api *token.Api, authCorpId, permanentCode string) (*Permanent, error)

GetAuthInfo 获取企业授权信息 POST(HTTPS) https://qyapi.weixin.qq.com/cgi-bin/service/get_auth_info?suite_access_token=SUITE_ACCESS_TOKEN

type PermanentInfo added in v1.0.13

type PermanentInfo struct {
	PermanentCode    string           `json:"permanent_code"`
	DealerCorpInfo   DealerCorpInfo   `json:"dealer_corp_info"`
	AuthCorpInfo     AuthCorpInfo     `json:"auth_corp_info"`
	AuthInfo         AuthInfo         `json:"auth_info"`
	AuthUserInfo     AuthUserInfo     `json:"auth_user_info"`
	RegisterCodeInfo RegisterCodeInfo `json:"register_code_info"`
	State            string           `json:"state"`
}

func (PermanentInfo) IsCustomizedApp added in v1.0.13

func (p PermanentInfo) IsCustomizedApp() bool

IsCustomizedApp 代开发模版授权,另外接口不返回access_token字段 授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个agent,对新的单应用授权,永远只返回一个agent

type PreAuthCode

type PreAuthCode struct {
	Code      string `json:"pre_auth_code"`
	ExpiresIn int64  `json:"expires_in"`
}

func GetPreAuthCode

func GetPreAuthCode(api *token.Api) (*PreAuthCode, error)

GetPreAuthCode 获取预授权码

type Privilege

type Privilege struct {
	Level      int      `json:"level"`
	AllowParty []int    `json:"allow_party"`
	AllowUser  []string `json:"allow_user"`
	AllowTag   []int    `json:"allow_tag"`
	ExtraParty []int    `json:"extra_party"`
	ExtraUser  []string `json:"extra_user"`
	ExtraTag   []int    `json:"extra_tag"`
}

type QRCodeReq

type QRCodeReq struct {
	SuiteId    string `json:"suite_id"`
	Appid      int    `json:"appid"`
	State      string `json:"state"`
	Style      int    `json:"style"`
	ResultType int    `json:"result_type"`
}

type RegisterCodeInfo

type RegisterCodeInfo struct {
	RegisterCode string `json:"register_code"`
	TemplateId   string `json:"template_id"`
	State        string `json:"state"`
}

type SharedFrom

type SharedFrom struct {
	CorpId    string `json:"corpid"`
	ShareType int    `json:"share_type"`
}

type SuiteTicket

type SuiteTicket struct {
	SuiteId     string `json:"SuiteId" xml:"SuiteId"`
	InfoType    string `json:"InfoType" xml:"InfoType"`
	SuiteTicket string `json:"SuiteTicket" xml:"SuiteTicket"`
	TimeStamp   int64  `json:"TimeStamp" xml:"TimeStamp"`
}

SuiteTicket 推送suite_ticket

type TagInfo

type TagInfo struct {
	TagId         int64    `json:"TagId" json:"TagId"`
	AddUserItems  []string `json:"AddUserItems" xml:"AddUserItems"`
	DelUserItems  []string `json:"DelUserItems" xml:"DelUserItems"`
	AddPartyItems []int64  `json:"AddPartyItems" xml:"AddPartyItems"`
	DelPartyItems []int64  `json:"DelPartyItems" xml:"DelPartyItems"`
}

type TagNotify

type TagNotify struct {
	HeadNotify // InfoType = change_contact, ChangeType = update_tag
	TagInfo
}

TagNotify 标签通知事件 回调设置在授权应用可见范围内的标签的变更事件。由第三方应用调用接口触发的标签变更事件不回调给该应用本身。

type UserDetail3rd

type UserDetail3rd struct {
	Corpid string `json:"corpid"`
	Userid string `json:"userid"`
	Name   string `json:"name"`
	Gender string `json:"gender"`
	Avatar string `json:"avatar"`
	QrCode string `json:"qr_code"`
}

func GetUserDetail3rd

func GetUserDetail3rd(api *token.Api, ticket string) (*UserDetail3rd, error)

GetUserDetail3rd 获取访问用户敏感信息 请求方式:POST(HTTPS) 请求地址:https://qyapi.weixin.qq.com/cgi-bin/service/auth/getuserdetail3rd?suite_access_token=SUITE_ACCESS_TOKEN

type UserInfo3rd

type UserInfo3rd struct {
	CorpId     string `json:"corpid"`
	Userid     string `json:"userid"`
	UserTicket string `json:"user_ticket"`
	ExpiresIn  int    `json:"expires_in"`
	OpenUserid string `json:"open_userid"`
}

func GetuserInfo3rd

func GetuserInfo3rd(api *token.Api, code string) (*UserInfo3rd, error)

GetuserInfo3rd 获取访问用户身份 请求方式:GET(HTTPS) 请求地址:https://qyapi.weixin.qq.com/cgi-bin/service/auth/getuserinfo3rd?suite_access_token=SUITE_ACCESS_TOKEN&code=CODE

Jump to

Keyboard shortcuts

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