📦 tencent-cloud-article-publisher — 技能工具
v1.0.0将文章自动发布到腾讯云开发者社区 (https://cloud.tencent.com/developer)。需要提供:标题、正文(Markdown 或纯文本)、Cookie 认证信息。支持直接发布(addArticle API),无需打开浏览器。
详细分析 ▾
运行时依赖
版本
Initial release of the Tencent Cloud article publisher skill: - Enables automatic article publishing to Tencent Cloud Developer Community via direct API. - Accepts title, Markdown or plain text content, and user-provided Cookie for authentication. - Converts Markdown to HTML for publishing; summary auto-generated if none provided. - No browser needed; articles are published immediately upon successful API call. - Ensures cookies are handled securely and only in memory; instructs users to retrieve cookies from browser DevTools. - Returns article link and publishing status after completion.
安装命令
点击复制技能文档
将文章直接发布到腾讯云开发者社区。
已验证的 API
发布端点: POST https://cloud.tencent.com/developer/api/article/addArticle
已确认成功响应的 payload:
{
"title": "文章标题",
"content": "HTML 格式正文内容
",
"plain": "纯文本正文(不含 HTML 标签)",
"summary": "文章摘要(自动生成或用户输入)",
"userSummary": "用户填写的摘要",
"sourceType": 1,
"isOriginal": true,
"classifyIds": [149],
"openComment": 1,
"closeTextLink": 0
}
成功响应: {"articleId":2650368,"status":0}
→ 文章立即发布成功,status=0 表示发布成功
发布流程
1. 转换内容格式
如果用户提供 Markdown → 转换为 HTML:
import redef md_to_html(md_text):
# 粗体
html = re.sub(r'\\(.+?)\\', r'\1', md_text)
# 斜体
html = re.sub(r'\(.+?)\', r'\1', html)
# 代码块
html = re.sub(r'(.+?)', r'\1', html)
# 换行
html = re.sub(r'\n', '
', html)
return f'
{html}
'
2. 直接调用 API
import requests import json
def publish_article(title, content_md, cookie_str): """直接发布文章到腾讯云开发者社区""" # 1. 转换格式 content_html = md_to_html(content_md) plain_text = content_md # 纯文本 # 2. 构建摘要 summary = content_md[:100] + '...' if len(content_md) > 100 else content_md # 3. API 调用 url = "https://cloud.tencent.com/developer/api/article/addArticle" headers = { "Cookie": cookie_str, "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36", "Content-Type": "application/json", "Referer": "https://cloud.tencent.com/developer/article/write-new", "Origin": "https://cloud.tencent.com", } payload = { "title": title, "content": content_html, "plain": plain_text, "summary": summary, "userSummary": summary, "sourceType": 1, "isOriginal": True, "classifyIds": [149], # 149 = 技术 "openComment": 1, "closeTextLink": 0 } resp = requests.post(url, headers=headers, json=payload, timeout=15) result = resp.json() if "articleId" in result: article_id = result["articleId"] article_url = f"https://cloud.tencent.com/developer/article/{article_id}" return {"success": True, "articleId": article_id, "url": article_url} else: return {"success": False, "error": result.get("msg", "Unknown error")}
3. 获取 Cookie
用户需要从浏览器 DevTools 获取:
- 打开 https://cloud.tencent.com/developer 并登录
- 按 F12 → Application → Cookies → cloud.tencent.com
- 复制以下 Cookie 字段的值,用分号连接:
skey
- qcloud_uid
- qcommunity_session
- loginType
- qcommunity_identify_id
- tinyid
- uin(可选)安全注意事项
- Cookie 仅存内存:不写入任何文件,用完即弃
- skey 包含特殊字符(
*):requests 库会自动处理,无需 URL 编码 - 有效期:Cookie 会过期,发布失败时提示用户刷新 Cookie
- 频率限制:每次发布间隔建议 > 10 秒
使用方式
用户说"帮我发布文章到腾讯云"时触发。收集:
- Cookie(从飞书私密消息传递)
- 文章标题
- 文章正文(支持 Markdown)
- 分类(可选,默认技术类)
返回发布结果 + 文章链接。