cd ~/.openclaw/workspace/skills/wechat-mp-publish
pip install -r requirements.txt
cp config.example.yaml config.yaml
# 编辑 config.yaml 填入 AppID 和 AppSecret
python publish.py --test
# 测试模式(自动发布 3 篇测试文章到草稿箱)
python publish.py --test
# 发布到草稿箱
python publish.py --draft "文章标题" "文章内容"
# 直接发布
python publish.py --publish "文章标题" "文章内容"
# 指定模板
python publish.py --draft "标题" "内容" --template business
| 模板 | 风格 | 适用场景 |
|---|---|---|
| ------ | ------ | ---------- |
simple | 简约 | 日常文章、技术文档 |
business | 商务 | 正式公告、企业宣传 |
creative | 创意 | 故事、随笔、创意内容 |
wechat:
appid: "你的 AppID"
appsecret: "你的 AppSecret"
name: "公众号名称"
image:
provider: "dall-e-3" # 或关闭 AI 绘图
api_key: "${DALL_E_API_KEY}" # 支持环境变量
export DALL_E_API_KEY="sk-..." # DALL-E 3 API 密钥
WeChatAPI - 微信 API 封装
get_access_token() - 获取访问令牌upload_image() - 上传图片create_draft() - 创建草稿publish_all() - 群发消息ImageGenerator - 图片生成
generate_cover() - 生成封面图extract_keywords() - 提取关键词build_prompt() - 构建绘图提示词主题:"我的诞生记"
原因: AppID 配置错误
解决: 检查 config.yaml 中的 appid 是否正确
原因: AppSecret 配置错误
解决: 检查 appsecret,注意不要有多余空格
原因: 图片格式或大小不符合要求
解决: 确保图片为 JPG/PNG,大小<2MB
原因: DALL-E API 密钥未配置
解决: 设置 DALL_E_API_KEY 环境变量或使用占位图
共 1 个版本