sidbusy / weixinmp Goto Github PK
View Code? Open in Web Editor NEW微信公众平台SDK for Go ### 请移步 https://github.com/go-with/wxmp ###
License: MIT License
微信公众平台SDK for Go ### 请移步 https://github.com/go-with/wxmp ###
License: MIT License
有些地方的变量不知写在哪,要导入些什么包?
<textMsg><ToUserName>xxxxxxx</ToUserName><FromUserName>xxxxxxxxx</FromUserName><CreateTime>1434807205</CreateTime><MsgType>text</MsgType><Content>hello ,world</Content></textMsg>
textMsg应该为xml的,但是源码中是有的,反射没有使用,如下:
// message structs 共用消息头
type msgHeader struct {
XMLName xml.Name `xml:"xml" json:"-"`
ToUserName string `json:"touser"`
FromUserName string `json:"-"`
CreateTime int64 `json:"-"`
MsgType string `json:"msgtype"`
}
查看api文档后,发现可以通过XMLName可以需改textMsg
,如果没有赋值就是使用类型名。
微信的api要求的格式是这样的:
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[你好]]></Content>
</xml>
func New(appId, appSecret string) *Message {
message := &Message{
Request: Request{Token: ""},
AccessToken: AccessToken{AppId: appId, AppSecret: appSecret},
}
// 要刷新token
token, _ := message.AccessToken.Fresh()
message.Request.Token = token
return message
}
can't load package: package github.com/aleafboat/weixinmp: found packages weixinmp (accesstoken.go) and main (main.go) in E:\wangchuanyi\go\src\github.com\xxx\weixinmp
错误: 进程退出代码 1. 我环境变量设置的没问题呀
接口很好用,希望添加获取用户信息等方面的接口,这样接口就基本完整了。
I use ReplyMusicMsg but failed. Then I remove MediaId and ThumbMediaId properties from Music structure. It success.
真受不了
最好有注释,详细说明文档,整一份。
我在使用这个接口的时候,这么使用
package main
import (
"log"
"net/http"
"github.com/sidbusy/weixinmp"
)
func main() {
// 注册处理函数
http.HandleFunc("/receiver", receiver)
log.Fatal(http.ListenAndServe(":80", nil))
}
func receiver(w http.ResponseWriter, r *http.Request) {
token := "" // 微信公众平台的Token
appid := "" // 微信公众平台的AppID
secret := "" // 微信公众平台的AppSecret
// 仅被动响应消息时可不填写appid、secret
// 仅主动发送消息时可不填写token
mp := weixinmp.New(token, appid, secret)
// 检查请求是否有效
// 仅主动发送消息时不用检查
if !mp.Request.IsValid(w, r) {
return
}
u := mp.Request.FromUserName
t, err := mp.GetUserInfo(u)
if err != nil {
fmt.Println(err)
}
fmt.Println(t.Nickname)
不能获取用户的t.Nickname,终端显示:
open accesstoken.tmp: permission denied
请问一下,是什么问题
mp.ReplyNewsMsg(w, &[]weixinmp.Article) 回复图文消息
这个如何使用呢?能否给个列子,谢谢,还有自定义菜单的,也能否给个列子,多谢了。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.