Code Monkey home page Code Monkey logo

go-wechat's Introduction

go-wechat

封装微信调用接口

install

go get github.com/MwlLj/go-wechat

import

import (
    "github.com/MwlLj/go-wechat"
    "github.com/MwlLj/go-wechat/common"
)

sample example

package main

import (
	"fmt"
	"github.com/MwlLj/go-wechat"
	"github.com/MwlLj/go-wechat/common"
)

var _ = fmt.Println

func main() {
	info := common.CUserInfo{
		AppId:     "your appid",
		AppSecret: "your appsecret",
		Port:      80,
		Url:       "/xxx",
		Token:     "your token",
	}
	wc := wechat.New(&info)
	wc.RegisterMsgFunc(func(reply common.IReply, msg *common.CMessage, userData interface{}) error {
		reply.SendMessage(msg)
		return nil
	}, nil)
	wc.Loop()
}

detail example

address

微信公众号测试帐号开发流程

1. 进入 https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
2. 填写基本信息
    appID: 自动生成
    appsecret: 自动生成
    URL: 接收微信服务器的url, 如果不配置 nginx, 必须用 80 端口(直接 http://ip/xxx)
    Token: 任意填写, 但是如果是正式版的公众号, 请写得复杂一些
3. 可以将上面的例子(记得将 AppId 等基本信息改成你自己的)放在远程服务器上, go run main.go
4. 点击测试帐号的 提交, 只有步骤3启动之后, 测试帐号的配置信息提交才会成功

go-wechat's People

Contributors

mwllj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.