本文整理汇总了Golang中github.com/chanxuehong/wechat/mp.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewClient
// 兼容保留, 建議實際項目全局維護一個 *mp.Client
func NewClient(srv mp.AccessTokenServer, clt *http.Client) Client {
return Client{
Client: internal.Client{
Client: mp.NewClient(srv, clt),
},
}
}
开发者ID:AddictXQ,项目名称:wechat,代码行数:8,代码来源:client.go
示例2: createMenu
func createMenu(w http.ResponseWriter, r *http.Request) {
log.Println("create menu: begin...")
fmt.Println("%v", r.Body)
var AccessTokenServer = mp.NewDefaultAccessTokenServer(AppId, AppSecret, nil) // 一個應用只能有一個實例
var mpClient = mp.NewClient(AccessTokenServer, nil)
var subButtons = make([]menu.Button, 2)
subButtons[0].SetAsViewButton("搜索", "http://www.soso.com/")
subButtons[1].SetAsClickButton("赞一下我们", "V1001_GOOD")
var testButtons = make([]menu.Button, 2)
testButtons[0].SetAsClickButton("今日歌曲", "V1001_TODAY_MUSIC")
testButtons[1].SetAsClickButton("来一张图片", "V1001_IMG")
var mn menu.Menu
mn.Buttons = make([]menu.Button, 3)
mn.Buttons[0].SetAsSubMenuButton("...", testButtons)
mn.Buttons[1].SetAsViewButton("视频", "http://v.qq.com/")
mn.Buttons[2].SetAsSubMenuButton("子菜单", subButtons)
menuClient := (*menu.Client)(mpClient)
if err := menuClient.CreateMenu(mn); err != nil {
fmt.Println(err)
return
}
fmt.Println("ok")
w.Write([]byte("create menu:success"))
}
开发者ID:kekek,项目名称:test,代码行数:31,代码来源:main.go
示例3: main
func main() {
var accessTokenServer = mp.NewDefaultAccessTokenServer("wx8dd685b36012ecb6", "8660ab2e951c442658467f2d0f2da440", nil)
var mpClient = mp.NewClient(accessTokenServer, nil)
var ticketServer = jssdk.NewDefaultTicketServer(mpClient)
for i := 0; i < 2; i++ {
ticket, err := ticketServer.Ticket()
fmt.Println("ticket:", ticket, err)
}
for i := 0; i < 2; i++ {
ticket, err := ticketServer.TicketRefresh()
fmt.Println("ticket refresh:", ticket, err)
}
}
开发者ID:rainsight,项目名称:test,代码行数:15,代码来源:in.go
示例4: Get
func (this *WelcomeController) Get() {
var AccessTokenServer = mp.NewDefaultAccessTokenServer("wxa2dc73d6e114eb30", "a058552dcb7da6dc4c0f646eecf3a92a", nil)
var mpClient = mp.NewClient(AccessTokenServer, nil)
var TicketServer = jssdk.NewDefaultTicketServer(mpClient)
tick, err := TicketServer.Ticket()
TicketServer.
if err != nil {
beego.Error(err)
}
this.Ctx.WriteString(tick)
jssdk.WXConfigSign(tick, nonceStr, timestamp, url)
// name := this.GetString("name")
// if IsChineseName(name) {
// this.Ctx.WriteString(name + "is")
// } else {
// this.Ctx.WriteString(name + "no")
// }
}
开发者ID:ruoL,项目名称:music,代码行数:18,代码来源:welcome.go
示例5: CreateMenu
func CreateMenu() {
AccessTokenServer := mp.NewDefaultAccessTokenServer(APPID, APPSECRET, nil) // 一個應用只能有一個實例
WechatClient := mp.NewClient(AccessTokenServer, nil)
clt := menu.NewClient(WechatClient.AccessTokenServer, WechatClient.HttpClient)
clt.DeleteMenu()
var mn menu.Menu
mn.Buttons = make([]menu.Button, 3)
mn.Buttons[0].SetAsViewButton("种犬展示", "http://test.lichengsoft.com/dogs")
mn.Buttons[1].SetAsViewButton("待售幼犬", "http://test.lichengsoft.com/pups")
var subButtons = make([]menu.Button, 3)
subButtons[0].SetAsViewButton("我要留言", "http://test.lichengsoft.com/comment")
subButtons[1].SetAsViewButton("关于灵睿", "http://test.lichengsoft.com/about")
subButtons[2].SetAsViewButton("登录灵睿", "http://test.lichengsoft.com/signin")
mn.Buttons[2].SetAsSubMenuButton("更多信息", subButtons)
if err := clt.CreateMenu(mn); err != nil {
fmt.Println(err)
return
}
fmt.Println("menu reset success !")
}
开发者ID:zileyuan,项目名称:hidog,代码行数:24,代码来源:controller.go
示例6: NewClient
func NewClient(srv mp.AccessTokenServer, clt *http.Client) *Client {
return (*Client)(mp.NewClient(srv, clt))
}
开发者ID:Wang,项目名称:wechat,代码行数:3,代码来源:client.go
示例7: main
"github.com/chanxuehong/wechat/mp"
"github.com/chanxuehong/wechat/mp/menu"
"github.com/chanxuehong/wechat/mp/message/request"
"github.com/chanxuehong/wechat/mp/message/response"
"github.com/garyburd/redigo/redis"
)
const (
AppId = "wx96ae3fe27ad45e53"
AppSecret = "ea4a0db81cc6a0017a69b0172515d5d8"
token = "wexin"
mediaId = "X9q8xoHV7-3W5E-ohorp_eiKp53vOv-2SUYipXHHA_A"
)
var AccessTokenServer = mp.NewDefaultAccessTokenServer(AppId, AppSecret, nil) // 一個應用只能有一個實例
var mpClient = mp.NewClient(AccessTokenServer, nil)
func main() {
messageServeMux := mp.NewMessageServeMux()
messageServeMux.MessageHandleFunc(request.MsgTypeText, TextMessageHandler) // 注册文本处理 Handler
//菜单事件处理
messageServeMux.EventHandleFunc(menu.EventTypeClick, EventMessageHandler) // 注册时间处理 Handler
//菜单跳转链接时间处理
messageServeMux.EventHandleFunc(menu.EventTypeView, ViewMessageHandler) // 注册时间处理 Handler
//菜单地理位置处理
messageServeMux.EventHandleFunc(menu.EventTypeLocationSelect, LocationEventSelectMessageHandle)
开发者ID:kekek,项目名称:test,代码行数:31,代码来源:main.go
注:本文中的github.com/chanxuehong/wechat/mp.NewClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论