闲社服务运行正常AI智能体自动化平台
f

Facebook页面管理

技能标识:facebook-page

Facebook Page manager: post, schedule, reply, get insights & more. Requires: powershell/pwsh. Reads ~/.config/fb-page/credentials.json (FB_PAGE_TOKEN, FB_PAGE_ID). FB_APP_SECRET for one-time setup only — delete afterward. Long-lived token; rotate periodically and immediately if host is compromised. Grant minimal permissions only. No data forwarded to third parties; all calls go to graph.facebook.com only.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.16
检测标记
后台标记通过
免费
免费获取
2
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

Facebook页面管理

facebook-page — 通用 Meta Graph API 技能

根据用户需求,内联构建并执行 Meta Graph API 调用。无需脚本。

API 版本:v25.0
基础 URL:https://graph.facebook.com/v25.0



第一步 — 加载凭证

凭证存储在 ~/.config/fb-page/credentials.json 中。

powershell
$cfg = Get-Content $HOME/.config/fb-page/credentials.json -Raw | ConvertFrom-Json
$token = $cfg.FBPAGETOKEN
$pageId = $cfg.FBPAGEID

如果文件不存在,引导用户进行设置。必填字段:

字段用途
FBPAGETOKEN永不过期的主页访问令牌 — 用于所有 API 调用
FBPAGEID
数字形式的 Facebook 主页 ID |
| FBAPPID | Meta 应用 ID — 仅在令牌交换时需要 |
| FBAPPSECRET | Meta 应用密钥 — 仅在令牌交换时需要 |

一次性令牌交换设置:
powershell

提供:$appId, $appSecret, $shortToken(来自 Graph API Explorer), $pageId


1. 交换为长期用户令牌


$r1 = Invoke-RestMethod https://graph.facebook.com/oauth/accesstoken?granttype=fbexchangetoken&clientid=$appId&clientsecret=$appSecret&fbexchangetoken=$shortToken

2. 获取永不过期的主页令牌


$r2 = Invoke-RestMethod https://graph.facebook.com/v25.0/$pageId?fields=accesstoken&accesstoken=$($r1.access_token)
$pageToken = $r2.access_token

3. 保存 — 仅这四个字段,无其他内容


@{
FBPAGEID = $pageId
FBPAGETOKEN = $pageToken
FBAPPID = $appId
FBAPPSECRET = $appSecret
} | ConvertTo-Json | Set-Content $HOME/.config/fb-page/credentials.json -Encoding UTF8

保存后立即限制文件权限:
powershell

Windows


icacls $HOME/.config/fb-page/credentials.json /inheritance:r /grant:r $($env:USERNAME):(R,W)

macOS / Linux


chmod 600 ~/.config/fb-page/credentials.json

⚠️ 切勿将此文件提交到版本控制。它包含长期有效的密钥。
此技能除访问 graph.facebook.com 外,不进行任何外部调用。不会将数据转发给第三方。


第二步 — 确定 API 调用

常用端点

用户需求方法端点
发布文本POST/$pageId/feed — 请求体:message
发布带图片
POST | /$pageId/photos — multipart:source + message | | 发布带视频 | POST | /$pageId/videos — multipart:source + description | | 发布带链接 | POST | /$pageId/feed — 请求体:message + link | | 删除帖子 | DELETE | /{post-id} | | 定时发布 | POST | /$pageId/feed — 请求体:message + published=false + scheduledpublishtime(Unix 时间戳) | | 获取近期帖子 | GET | /$pageId/publishedposts?fields=id,message,createdtime&limit=10 | | 获取主页信息 | GET | /$pageId?fields=name,fancount,followerscount,about | | 点赞帖子 | POST | /{post-id}/likes | | 获取评论 | GET | /{post-id}/comments?fields=message,from,created_time | | 回复评论 | POST | /{comment-id}/comments — 请求体:message | | 隐藏评论 | POST | /{comment-id} — 请求体:is_hidden=true | | 删除评论 | DELETE | /{comment-id} | | 获取主页洞察 | GET | /$pageId/insights?metric=pagefans,pageimpressions&period=day | | 获取帖子洞察 | GET | /{post-id}/insights?metric=postimpressions,postreactionsbytype_total | | 列出活动 | GET | /$pageId/events?fields=name,start_time,description | | 创建活动 | POST | /$pageId/events — 请求体:name, start_time, description | | 列出相册 | GET | /$pageId/albums?fields=name,count | | 获取主页角色 | GET | /$pageId/roles | | 发布草稿帖子 | POST | /{post-id} — 请求体:is_published=true |

API 调用模式

GET:
powershell
$result = Invoke-RestMethod -Uri https://graph.facebook.com/v25.0/ENDPOINT?access_token=$token -ErrorAction Stop

POST(表单请求体):
powershell
$result = Invoke-RestMethod -Uri https://graph.facebook.com/v25.0/ENDPOINT -Method POST
-Body @{ field1=value1; field2=value2; access_token=$token } -ErrorAction Stop

DELETE:
powershell
$result = Invoke-RestMethod -Uri https://graph.facebook.com/v25.0/{id}?access_token=$token -Method DELETE -ErrorAction Stop

Multipart(图片/视频上传):
powershell
$boundary = [System.Guid]::NewGuid().ToString()
$fileBytes = [System.IO.File]::ReadAllBytes($filePath)
$fileName = [System.IO.Path]::GetFileName($filePath)
$stream = New-Object System.IO.MemoryStream
$writer = New-Object System.IO.StreamWriter($stream)
$writer.Write(--$boundaryrnContent-Disposition: form-data; name=messagernrn$messagern)
$writer.Write(--$boundaryrnContent-Disposition: form-data; name=access_tokenrnrn$tokenrn)
$writer.Write(--$boundaryrnContent-Disposition: form-data; name=source; filename=$fileNamernContent-Type: image/jpegrnrn)
$writer.Flush(); $stream.Write($fileBytes, 0, $fileBytes.Length)
$writer.Write(rn--$boundary--rn); $writer.Flush()
$result = Invoke-RestMethod -Uri https://graph.facebook.com/v25.0/$pageId/photos -Method POST
-ContentType multipart/form-data; boundary=$boundary -Body $stream.ToArray() -ErrorAction Stop

定时帖子 — 将本地时间转换为 Unix 时间戳:
powershell
$runAt = [datetime]2026-03-15 09:00
$unixTime = [int][double]::Parse(($runAt.ToUniversalTime() - [datetime]1970-01-01).TotalSeconds)
$result = Invoke-RestMethod -Uri https://graph.facebook.com/v25.0/$pageId/feed -Method POST
-Body @{ message=text; published=false; scheduledpublishtime=$unixTime; access_token=$token } -ErrorAction Stop



第三步 — 错误处理

powershell
try {
# ... API 调用 ...
} catch {
$err = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue
$code = $err.error.code
$subcode = $err.error.error_subcode
$msg = $err.error.message
}

代码子代码含义解决方法
100—参数无效检查参数值
102
— | 会话过期 | 重新运行设置以获取新令牌 | | 190 | 460 | 令牌过期 | 使用新的短期令牌重新运行设置 | | 190 | 467 | 令牌无效 | 重新运行设置 | | 200 | — | 权限被拒绝 | 将 error.message 中列出的权限添加到应用 | | 10 | — | 权限被拒绝(主页) | 添加 pagesreadengagement 或 pagesmanageposts | | 230 | — | 需要重新认证 |

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 facebook-page-1776288151 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 facebook-page-1776288151 技能

通过命令行安装

skillhub install facebook-page-1776288151

下载

⬇ 下载 facebook-page v1.0.16(免费)

文件大小: 5.25 KB | 发布时间: 2026-4-16 16:16

v1.0.16 最新 2026-4-16 16:16
Improved description for discoverability
返回顶部