在微信小程序中有获取小程序码功能(参照:小程序文档),使用beego想要直接将生成的二维码返回给前端,具体代码如下:
post := httplib.Post("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + wxToken.Access_token)
var body = "{\"path\":\"?test\",\"width\":430,\"auto_color\":false,\"line_color\":{\"r\":\"0\",\"g\":\"0\",\"b\":\"0\"}}"
post.Body(body)
response, _ := post.Response()
bytes, _ := ioutil.ReadAll(response.Body)
c.Ctx.WriteString(string(bytes))