{"id":21020622,"url":"https://github.com/5ime/goodmorning","last_synced_at":"2025-05-15T07:34:14.315Z","repository":{"id":127514187,"uuid":"527972856","full_name":"5ime/GoodMorning","owner":"5ime","description":"利用微信服务号实现早安自动化","archived":false,"fork":false,"pushed_at":"2022-08-23T12:15:26.000Z","size":4,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T05:51:07.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5ime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-08-23T12:07:05.000Z","updated_at":"2023-11-21T13:20:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd2f9009-7393-4d88-a4f3-78b60ee1cd0f","html_url":"https://github.com/5ime/GoodMorning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5ime%2FGoodMorning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5ime%2FGoodMorning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5ime%2FGoodMorning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5ime%2FGoodMorning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5ime","download_url":"https://codeload.github.com/5ime/GoodMorning/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254297402,"owners_count":22047486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-19T10:42:23.680Z","updated_at":"2025-05-15T07:34:14.307Z","avatar_url":"https://github.com/5ime.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 利用微信服务号实现早安自动化\n\n## 功能简介\n\n- 支持100人群发/10个模板(不可能所有的宝都叫一个名字吧)，舔一个人叫舔，舔一百个人叫…\n- 实时通知推送成功/失败数量和具体名字\n\n## 效果预览\n\n注：推送提醒 仅主人才会收到\n\n![image](https://user-images.githubusercontent.com/31686695/186155177-3957ede4-21a2-4a8d-8add-5b681afc4b47.png)\n\n\n## 食用方法\n\n### 申请测试号\n\n前往 `微信公众平台` 申请 `接口测试帐号` ，因为只有 `服务号` 有 `模板消息` 推送功能， `订阅号`没有（ `服务号` 需要 `企业` 才能申请\n\n`https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login`\n\n### 获取appID和appsecret\n\n登录过后我们得到一个测试号，我们需要保存的信息 `appID` 和 `appsecret`\n\n![image](https://user-images.githubusercontent.com/31686695/186154966-621fa612-5645-4127-bd35-3983b7d4eb48.png)\n\n### 获取微信号\n\n假设我们们要推送给张三，让张三扫描左侧的 `测试号二维码` 关注，右侧会列出 `微信号` ，我们把需要推送的用户的 `微信号` 保存下来\n\n![image](https://user-images.githubusercontent.com/31686695/186155009-99f7b90e-cdd8-46d5-aab1-5a9a27961cd6.png)\n\n\n### 获取模板ID\n\n我们在 `模板消息接口` 中点击 `新建测试模板` ，`模板标题` 即为推送卡片的标题，这里博主填写为 `早安呀~` ， `模板内容` 填入如下内容\n\n```\n今日天气: {{weather.DATA}}\n当前温度: {{temp.DATA}}\n今日温度: {{tempRange.DATA}}\n今天是我们的第 {{loveDay.DATA}} 天\n距离你的生日还有 {{birthDay.DATA}} 天\n{{rainbow.DATA}}\t\n```\n\n![image](https://user-images.githubusercontent.com/31686695/186155021-5f8de82e-4f06-4555-b0e6-bdc7d42ab72d.png)\n\n我们再次重复上面的步骤，`模板标题` 填写 `推送提醒` ， `模板内容` 填入如下内容\n\n```\n共推送 {{count.DATA}} 人\n成功: {{successNum.DATA}} | 失败: {{errorNum.DATA}}\n成功用户: {{success.DATA}}\n失败用户: {{error.DATA}}\t\n```\n\n这样我们就得到了两个 `模板ID` ，保存下来。\n\n![image](https://user-images.githubusercontent.com/31686695/186155054-3d198c0e-587a-41b7-90d2-2342c6ea07ce.png)\n\n## 填写配置\n\n目前的得到的信息清单如下，直接对照着填入下面的 `php` 代码中即可\n\n```\nappID,appsecret,微信号,两个模板ID\n```\n\n---\n```php\n$config = array(\n    'APP_ID' =\u003e 'appID',\n    'APP_SECRET' =\u003e 'appsecret',\n    'TEMPLATE_ID' =\u003e '默认模板ID',\n    // 一次舔多人,最多可以舔100个人,模板最多只能10个\n    'user' =\u003e array(\n        array(\n            // name可看做是备注\n            'name' =\u003e '001',\n            'id' =\u003e '被推送人的微信号',\n            // 这里是开始恋爱的日期，格式必须是 2017-01-01\n            'date' =\u003e '2017-01-01',\n            // 城市只定位到市级即可\n            'city' =\u003e '潍坊',\n            // 这里是对方的生日日期，格式必须是 05-20\n            'birthday' =\u003e '05-20',\n            // 每个编号可对应一个模板,为空则使用默认模板ID\n            'TEMPLATE_ID' =\u003e '早安呀的模板ID',\n        ),\n        // 这里是多用户写法\n        // array(\n        //     'name' =\u003e '002',\n        //     'id' =\u003e '被推送人的微信号',\n        //     'date' =\u003e '2017-01-01',\n        //     'city' =\u003e '德州',\n        //     'birthday' =\u003e '05-20',\n        //     'TEMPLATE_ID' =\u003e '',\n        // ),\n    ),\n    // 用来推送是否成功\n    'MASTER_ID' =\u003e '主人的微信号',\n    'MASTER_TEMPLATE_ID' =\u003e '推送提醒的模板ID',\n);\n```\n\n## 定时推送\n\n我们可以把上面的 `php` 文件上传到网站中，使用宝塔计划任务进行触发，或者说写个 `shell` 脚本，`python` 脚本之类的搭配 `crontab` 定时触发\n\n![image](https://user-images.githubusercontent.com/31686695/186155115-c75e8030-6af7-4dc3-b504-2e621714559a.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5ime%2Fgoodmorning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5ime%2Fgoodmorning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5ime%2Fgoodmorning/lists"}