{"id":44602953,"url":"https://github.com/zyh94946/wx-msg-push-tencent","last_synced_at":"2026-02-14T10:08:09.127Z","repository":{"id":57580883,"uuid":"347869159","full_name":"zyh94946/wx-msg-push-tencent","owner":"zyh94946","description":"基于腾讯云云函数和API网关实现的企业微信应用消息推送服务","archived":false,"fork":false,"pushed_at":"2022-05-22T06:42:05.000Z","size":31195,"stargazers_count":55,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-18T21:48:40.438Z","etag":null,"topics":["golang","push-notifications","serverless-functions"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zyh94946.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}},"created_at":"2021-03-15T07:02:40.000Z","updated_at":"2024-06-11T03:45:31.000Z","dependencies_parsed_at":"2022-09-26T18:52:02.173Z","dependency_job_id":null,"html_url":"https://github.com/zyh94946/wx-msg-push-tencent","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/zyh94946/wx-msg-push-tencent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyh94946%2Fwx-msg-push-tencent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyh94946%2Fwx-msg-push-tencent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyh94946%2Fwx-msg-push-tencent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyh94946%2Fwx-msg-push-tencent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zyh94946","download_url":"https://codeload.github.com/zyh94946/wx-msg-push-tencent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyh94946%2Fwx-msg-push-tencent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29442356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: 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":["golang","push-notifications","serverless-functions"],"created_at":"2026-02-14T10:08:05.701Z","updated_at":"2026-02-14T10:08:09.121Z","avatar_url":"https://github.com/zyh94946.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 基于腾讯云Serverless实现的企业微信应用消息推送服务\n\n## Serverless 云函数 计费模式和免费额度于 2022 年 6 月 1 日进行调整，请参考[免费额度](https://cloud.tencent.com/document/product/583/12282)\n\n~~Serverless 云函数目前每月有免费资源使用量40万GBs、免费调用次数100万次~~\n\nAPI网关目前开通即送时长12个月100万次免费额度\n\n个人或者低频率使用完全够了，可以通过 GET、POST 方式调用发消息。\n\n对于有服务器、域名资源，~~通过简单修改~~也可以直接部署到服务器上。\n\n**独立部署版见 [wx-msg-push](https://github.com/zyh94946/wx-msg-push)**\n\n## 消息效果\n\n\u003cdetails\u003e\n\u003csummary\u003e点击展开\u003c/summary\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/demo.gif\" width=\"50%\" /\u003e\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/demo_text.png\" width=\"50%\" /\u003e\n\u003c/details\u003e\n\n不用安装企业微信App，直接通过微信App关注微信插件即可实现在微信App中接收应用消息，还可以选择消息免打扰。\n\n## 消息限制\n\n目前支持发送的应用消息类型为：\n\n1. 图文消息(mpnews)，消息内容支持html标签，不超过666K个字节，会自动生成摘要替换br标签为换行符，过滤html标签。\n2. 文本消息(text)，消息内容最长不超过2048个字节，超过将截断。\n3. markdown消息(markdown)，markdown内容，最长不超过2048个字节，必须是utf8编码。([支持的markdown语法](https://work.weixin.qq.com/api/doc/90000/90135/90236#%E6%94%AF%E6%8C%81%E7%9A%84markdown%E8%AF%AD%E6%B3%95))\n\n每企业消息发送不可超过帐号上限数*30人次/天（注：若调用api一次发给1000人，算1000人次；若企业帐号上限是500人，则每天可发送15000人次的消息）\n\n每应用对同一个成员不可超过30条/分，超过部分会被丢弃不下发\n\n默认已启用重复消息推送检查5分钟内同样内容的消息，不会重复收到，可修改 `EnableDuplicateCheck` `DuplicateCheckInterval` 调整是否开启与时间间隔。\n\n## 部署方式\n\n首先注册[企业微信](https://work.weixin.qq.com/)\n\n### 创建应用\n\n登录[企业微信web管理](https://work.weixin.qq.com/)\n\n进入 `应用管理` ， `创建应用` ，完成后复制下 `AgentId` `Secret` 。\n\n(如果仅使用文本消息可跳过此步) 进入 `管理工具` ， `素材库` ， `图片` ， `添加图片` （这个图片是图文消息的展示图），上传成功后在图片下载按钮上复制下载地址\n\n\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/media.png\" /\u003e\n\n(如果仅使用文本消息可跳过此步) 把url的 `media_id` 值复制下备用\n\n进入 `我的企业` ，把 `企业ID` 复制下，进入 `微信插件` ，用微信APP扫 `邀请关注` 的二维码码即可在微信App中查看企业微信消息。\n\n\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/info.png\" /\u003e\n\n### 注册腾讯云账号\n\n[腾讯云](https://cloud.tencent.com/)\n\n### 新建云函数\n\n[云函数](https://console.cloud.tencent.com/scf/index)\n\n如果想要绑定域名的话可以选择香港地区，免备案。\n\n从 releases 中下载 `linux-amd64` 的预编译 zip 包。\n\n选择 `自定义创建` ， `运行环境` `Go1` ， `提交方法` 选择 `本地上传zip包` 选择刚才的 zip 包。\n\n\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/cf1.png\" /\u003e\n\n`高级配置` 中增加 `环境变量`\n\n- CORP_ID 企业微信 企业id\n- CORP_SECRET 企业微信 应用Secret\n- AGENT_ID 企业微信 应用AgentId\n- MEDIA_ID 企业微信 图片素材的media_id(如果仅使用文本消息可随意填写)\n\n`触发器` 配置选择 `自定义配置` ，触发方式选择 `API网关触发`\n\n点击 `完成` 开始创建\n\n### 设置API网关\n\n[Api网关](https://console.cloud.tencent.com/apigateway/service)\n\n进入 `API网关` 服务列表，选择 `配置管理` ，然后 `管理API` 点 `编辑`\n\n\u003cimg src=\"https://raw.githubusercontent.com/zyh94946/wx-msg-push-tencent/main/demo/api1.png\" /\u003e\n\n增加 `参数配置` ，参数名 `SECRET` ，参数位置 `path`，类型 `string`\n\n路径修改为 `/你的云函数名称/{SECRET}`\n\n然后点 `立即完成` 发布服务\n\n在 `基础配置` 中复制 `公网访问地址` ，想要绑定域名可以在 `自定义域名` 中绑定，CNAME指到API网关的二级域名，自定义路径映射 `/` 路径 到 `发布` 环境。\n\n## 使用方法\n\n消息类型值：`text` 代表文本消息，`mpnews` 代表图文消息，`markdown` 代表 markdown 消息。为兼容旧版本，不传默认为图文消息。\n\n支持推送消息至指定的 `touser`, `toparty`, `totag`。不传默认设置 `touser=@all` \n\nGET方式\n\n`https://你的Api网关域名/你的云函数名称/CORP_SECRET?title=消息标题\u0026content=消息内容\u0026type=消息类型`\n\nPOST方式\n\n```bash\n$ curl --location --request POST 'https://你的Api网关域名/你的云函数名称/CORP_SECRET' \\\n--header 'Content-Type: application/json;charset=utf-8' \\\n--data-raw '{\"title\":\"消息标题\",\"content\":\"消息内容\",\"type\":\"消息类型\"}'\n```\n\n发送成功状态码返回200，`\"Content-Type\":\"application/json\"` body `{\"errorCode\":0,\"errorMessage\":\"\"}` 。\n\n## 其它\n\n发送失败问题排查：\n\n- 请检查云函数环境变量是否正确\n- 请检查发送url中CORP_SECRET是否正确\n- 请检查Api网关SECRET参数是否设置\n- 进入云函数后台查看请求日志的具体错误原因\n\n## 更新记录\n\n- 2021-04-11 支持文本消息，优化代码结构方便新增其它消息类型。\n- 2021-04-29 支持推送消息至指定的`touser`, `toparty`, `totag`。\n- 2021-09-13 支持markdown消息类型。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyh94946%2Fwx-msg-push-tencent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzyh94946%2Fwx-msg-push-tencent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyh94946%2Fwx-msg-push-tencent/lists"}