{"id":37122784,"url":"https://github.com/zsmhub/wx-channels-sdk","last_synced_at":"2026-01-14T14:11:20.517Z","repository":{"id":65732726,"uuid":"596349930","full_name":"zsmhub/wx-channels-sdk","owner":"zsmhub","description":"Go语言实现微信视频号sdk（自建应用维度），集成了视频号小店(微信小店)和视频号橱窗的功能，使用简单，扩展灵活","archived":false,"fork":false,"pushed_at":"2025-06-03T01:31:34.000Z","size":140,"stargazers_count":27,"open_issues_count":0,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T16:14:46.782Z","etag":null,"topics":["channels","sdk","shipinhao","shop","wechat","weixin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zsmhub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-02T01:38:20.000Z","updated_at":"2025-06-03T01:30:33.000Z","dependencies_parsed_at":"2023-11-06T11:24:18.015Z","dependency_job_id":"7cbf6943-cc71-4324-b1a5-7694c484ac7e","html_url":"https://github.com/zsmhub/wx-channels-sdk","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/zsmhub/wx-channels-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsmhub%2Fwx-channels-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsmhub%2Fwx-channels-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsmhub%2Fwx-channels-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsmhub%2Fwx-channels-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zsmhub","download_url":"https://codeload.github.com/zsmhub/wx-channels-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zsmhub%2Fwx-channels-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["channels","sdk","shipinhao","shop","wechat","weixin"],"created_at":"2026-01-14T14:11:19.918Z","updated_at":"2026-01-14T14:11:20.504Z","avatar_url":"https://github.com/zsmhub.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 微信视频号 GO SDK\n\n\u003e “视频号小店”在2024年9月25日正式更名为“微信小店”，API调用不受影响。\n\n- [微信小店-官方接口文档](https://developers.weixin.qq.com/doc/store/shop/API/apimgnt/api_getaccesstoken.html)\n- [视频号小店-官方接口文档](https://developers.weixin.qq.com/doc/channels/API/basics/getaccesstoken.html)\n\nGo语言实现微信视频号sdk（自建应用维度），集成了视频号小店和视频号橱窗的功能，使用简单，扩展灵活\n\n- 支持一键生成sdk代码，包括api和回调事件\n- 用缓存方案实现分布式 access_token，保证在多个服务中只有一个服务能成功调用API请求 access_token，减少API调用次数和服务重启需要重新获取的情况\n    + 缓存方案支持自定义存储，默认内存存储\n- 支持自定义日志存储，提供Logger interface：用于自行实现日志记录器，便于收集日志\n    + 默认 log.Printf 输出\n\n[点击查看视频号的开发博文](https://zsmhub.github.io/post/%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B/%E5%BE%AE%E4%BF%A1%E8%A7%86%E9%A2%91%E5%8F%B7/)\n\n### 安装命令\n\n```sh\ngo get github.com/zsmhub/wx-channels-sdk\n```\n\n### 一键生成sdk代码命令（`需手动格式化代码`）\n\n- 生成视频号回调事件代码\n\n    ```sh\n    make callback doc=文档链接\n\n    # example\n    make callback doc=https://developers.weixin.qq.com/doc/channels/API/product/callback/ProductSpuListing.html\n    ```\n\n- 生成视频号api代码\n\n    ```sh\n    make api doc=文档链接 [prefix=生成文件名前缀]\n\n    # example\n    make api doc=https://developers.weixin.qq.com/doc/channels/API/product/get.html prefix=商品\n    ```\n\n    \u003e tip：\n    \u003e 1. Get 方式的接口量少没做兼容，请求参数需手动整理到 Req 结构体，Post 则不用\n    \u003e 2. 部分接口文档的请求/响应 json 示例，如果缺少部分字段，需手动补上\n    \u003e 3. 部分复杂的页面需要手动整理下sdk\n\n### sdk调用示例\n\n**强烈建议去 ./demo 文件夹查看完整示例！**\n\n[点击查看完整demo](https://github.com/zsmhub/wx-channels-sdk/tree/main/demo)\n\n#### 回调事件sdk调用示例\n\n```go\n// 回调事件初始化\nfunc (callbackRepo) InitCallbackHandler() error {\n\t// 视频号小店回调事件解析\n\tif err := channels.Sdk.NewShopCallbackHandler(ShopCallbackToken, ShopCallbackEncodingAESKey); err != nil {\n\t\treturn err\n\t}\n\n\t// 视频号橱窗回调事件解析\n\tif err := channels.Sdk.NewWindowCallbackHandler(WindowCallbackToken, WindowCallbackEncodingAESKey); err != nil {\n\t   return err\n\t}\n\n\treturn nil\n}\n\n// 视频号小店-解析并获取回调信息\nmsg, err := channels.Sdk.ShopCallback.GetCallbackMsg(c.Request())\n\n// 视频号橱窗-解析并获取回调信息\nmsg, err := channels.Sdk.WindowCallback.GetCallbackMsg(c.Request())\n\n\n// 视频号小店-处理回调事件完整示例\nfunc (callbackRepo) HandleShopPostReqShouest(c echo.Context) error {\n\tmsg, err := channels.Sdk.ShopCallback.GetCallbackMsg(c.Request())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\t_ = recover()\n\t\t}()\n\n\t\tswitch msg.MsgType {\n\n\t\tcase callbacks.MessageTypeEvent:\n\t\t\tswitch msg.EventType {\n\n\t\t\tcase callbacks.EventTypeProductSpuAudit:\n\t\t\t\textras, ok := msg.Extras.(callbacks.EventProductSpuAudit)\n\t\t\t\tif !ok {\n\t\t\t\t\tfmt.Println(\"获取商品审核回调参数失败\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"接收到商品审核事件的原始内容：%s\\n\", msg.OriginalMessage)\n\t\t\t\tfmt.Printf(\"解析商品审核事件的结构体：%+v\\n\", extras)\n\t\t\t}\n\n\t\t}\n\t}()\n\n\treturn nil\n}\n```\n\n#### api sdk 调用示例\n\n```go\n// API客户端初始化\nfunc initApiHandler() error {\n\t// 初始化sdk参数\n\tchannels.Sdk.InitOptions(apis.Options{\n\t\tDcsToken: DcsTokenByRedis{},\n\t\tLogger:   Logger{},\n\t})\n\n\t// 视频号小店API客户端初始化\n\tchannels.Sdk.NewShopApiClient(ShopAppId, ShopAppSecret)\n\n\t// 视频号橱窗API客户端初始化\n\tchannels.Sdk.NewWindowApiClient(WindowAppId, WindowAppSecret)\n\n\treturn nil\n}\n\n// 获取 access_token\nresp, err := channels.Sdk.ShopClient.GetToken()\n\n// 获取店铺信息\nresp, err := channels.Sdk.ShopClient.ExecEcBasicsInfoGet(apis.ReqEcBasicsInfoGet{})\n\n// error code 类型强制转换\nif err != nil {\n\tif apiError, ok := err.(*apis.ClientError); ok {\n\t\tif apiError.Code == apis.ErrCode40013 {\n\t\t\treturn errors.New(\"不合法的 AppID\")\n\t \t}\n\t}\n\treturn nil, err\n}\n\n```\n\n### 目录结构\n\n```sh\n.\n├── apis                     视频号API\n│   └── api.error.go         全局错误码\n├── callbacks                视频号回调事件\n│   └── callback_constant.go 回调事件常量定义\n├── demo                     sdk调用示例\n├── generate                 一键生成脚本\n│   ├── api.go               一键生成视频号API脚本\n│   └── callback.go          一键生成企微回调事件脚本\n├── internal                 消息加解密库\n├── constant.go              全局枚举值定义\n└── sdk.go                   入口文件\n```\n\n### 注意点\n\n- 如果你发现了sdk中，没有某个回调事件或某个api，可以使用一键生成sdk代码命令生成，然后提交下pr\n- 注意视频号access_token不支持互刷，获取了新的access_token，旧的access_token就会很快失效\n\n### 推荐开源项目\n\n- [企业微信 GO SDK](https://github.com/zsmhub/workweixin)\n- [抖店开放平台 GO SDK](https://github.com/zsmhub/doudian-sdk)\n- [微信视频号 GO SDK](https://github.com/zsmhub/wx-channels-sdk)\n- [小红书开放平台 GO SDK](https://github.com/zsmhub/xhs-sdk)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsmhub%2Fwx-channels-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzsmhub%2Fwx-channels-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsmhub%2Fwx-channels-sdk/lists"}