wechat

package module
v0.0.0-...-79e6a84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2018 License: MIT Imports: 17 Imported by: 0

README

wechat-go

🎉微信小程序,微信小程序Api请求基础SDK

项目迁移至 https://github.com/nilorg/go-wechat

Example 🌰

package wechat

import (
	"fmt"
	"testing"
)

func init() {
	AppID = "123"
	AppSecret = "abc"
}

func TestExecute(t *testing.T) {
	// 小程序登录
	url := "https://api.weixin.qq.com/sns/jscode2session"
	param := Parameter{
		"js_code":    "登录时获取的 code",
		"grant_type": "authorization_code",
	}
	json, err := Execute(url, param)
	if err != nil {
		t.Fatal(err)
	}
	fmt.Println(json)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AppID 应用Key
	AppID = ""
	// AppSecret 秘密
	AppSecret = ""
)

Functions

func Decrypt

func Decrypt(value string) ([]byte, string)

Decrypt 解密

func Encrypt

func Encrypt(value string) string

Encrypt 加密

func Execute

func Execute(url string, param Parameter) (json *simplejson.Json, err error)

Execute 执行

func Get

func Get(url string, args map[string]string) (result []byte, err error)

Get send get request.

func GetErrorMsg

func GetErrorMsg(code int) string

GetErrorMsg 获取error msg

func NewError

func NewError(buf []byte) error

NewError 创建错误

func Post

func Post(url, contentType string, args map[string]string) (result string, err error)

Post send post request.

func PostJSON

func PostJSON(url string, jsonObject interface{}) (result []byte, err error)

PostJSON send post request.

func Upload

func Upload(uri, filename string, description *VideoDescription, srcFile io.Reader) (result []byte, err error)

Upload send post request.

Types

type CDATA

type CDATA string

CDATA ...

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML ...

type JSONer

type JSONer interface {
	JSON() string
}

JSONer json接口

type Parameter

type Parameter map[string]string

Parameter 参数

type VideoDescription

type VideoDescription struct {
	Title        string `json:"title"`        // 视频素材的标题
	Introduction string `json:"introduction"` // 视频素材的描述
}

VideoDescription 视频描述

type XMLer

type XMLer interface {
	XML() string
}

XMLer xml接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL