代码拉取完成,页面将自动刷新
package component
import (
"gitee.com/vibly/wechat-sdk/mp/core"
)
func OpenBindGet(clt *core.Client) (openAppId string, err error) {
const incompleteURL = "https://api.weixin.qq.com/cgi-bin/open/get?access_token="
var result struct {
core.Error
OpenAppId string `json:"open_appid"`
}
var request = struct {
AppId string `json:"appid"`
}{}
if err = clt.PostJSON(incompleteURL, &request, &result); err != nil {
return
}
if result.ErrCode != core.ErrCodeOK {
err = &result.Error
return
}
openAppId = result.OpenAppId
return
}
func CreateOpenAndBind(clt *core.Client, appId string) (openAppId string, err error) {
const incompleteURL = "https://api.weixin.qq.com/cgi-bin/open/create?access_token="
var result struct {
core.Error
OpenAppId string `json:"open_appid"`
}
var request = struct {
AppId string `json:"appid"`
}{
AppId: appId,
}
if err = clt.PostJSON(incompleteURL, &request, &result); err != nil {
return
}
if result.ErrCode != core.ErrCodeOK {
err = &result.Error
return
}
openAppId = result.OpenAppId
return
}
func OpenBind(clt *core.Client, appId string, openAppId string) (err error) {
const incompleteURL = "https://api.weixin.qq.com/cgi-bin/open/bind?access_token="
var result struct {
core.Error
}
var request = struct {
AppId string `json:"appid"`
OpenAppId string `json:"open_appid"`
}{
AppId: appId,
OpenAppId: openAppId,
}
if err = clt.PostJSON(incompleteURL, &request, &result); err != nil {
return
}
if result.ErrCode != core.ErrCodeOK {
err = &result.Error
return
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。