Esempio n. 1
0
File: upload.go Progetto: kekek/test
func main() {

	imagePath := "../img/IMG_0129.JPG"
	accessTokenSer := mp.NewDefaultAccessTokenServer(AppId, AppSecret, nil)

	//	临时素材
	//	client := media.NewClient(accessTokenSer,nil)

	client := material.NewClient(accessTokenSer, nil)
	mediaInfo, url, err := client.UploadImage(imagePath)

	/* 返回结果
	//临时素材
	{image SQP8zwCqsiJP02ccSx2cY80w6e5q1K0FUH2QA5m8aPgQA3Ys0Xsxal8Li21sg_ia 1448586880}

	//永久素材
	mediaInfo :  X9q8xoHV7-3W5E-ohorp_eiKp53vOv-2SUYipXHHA_A
	url :  https://mmbiz.qlogo.cn/mmbiz/u3RgicO3YCJa2aljOxNXWHKOU8tvenDZWVTCqptOn71bo2OCKr5A6xTSJDxwaZFoHPewvSPC3Xbw9ibX9DWvMsmQ/0?wx_fmt=jpeg

	*/
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println("mediaInfo : ", mediaInfo)
	fmt.Println("url : ", url)

}
Esempio n. 2
0
File: main.go Progetto: kekek/test
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"))
}
Esempio n. 3
0
File: in.go Progetto: rainsight/test
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)
	}
}
Esempio n. 4
0
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")
	// }
}
Esempio n. 5
0
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 !")
}
Esempio n. 6
0
File: main.go Progetto: kekek/test
	"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

	//菜单地理位置处理
Esempio n. 7
0
package main

import (
	"github.com/astaxie/beego"
	//	"github.com/astaxie/beego/logs"
	"github.com/chanxuehong/wechat/mp"
	"github.com/chanxuehong/wechat/mp/menu"
	_ "maihaoguo/routers"
	. "maihaoguo/util"
)

var AccessTokenServer = mp.NewDefaultAccessTokenServer("wx8657df9e66c8277d", "2b94ba328f84216c4eb2bfa0a6cbce82", nil) // 一個應用只能有一個實例
var mpClient = mp.NewClient(AccessTokenServer, nil)

func main() {
	beego.Run()
	var mn menu.Menu
	mn.Buttons = make([]menu.Button, 3)
	mn.Buttons[0].SetAsClickButton("我买果", "V1001_TODAY_MUSIC")
	mn.Buttons[1].SetAsViewButton("我卖果", "http://v.qq.com/")

	var subButtons = make([]menu.Button, 2)
	subButtons[0].SetAsViewButton("京郊水果", "http://www.soso.com/")
	subButtons[1].SetAsClickButton("进口精品", "V1001_GOOD")

	mn.Buttons[2].SetAsSubMenuButton("加入我们", subButtons)

	clt := menu.Client{Client: mpClient}
	if err := clt.CreateMenu(mn); err != nil {
		Log.Info(err.Error())
		return