instagram by vm0-ai/vm0-skills
npx skills add https://github.com/vm0-ai/vm0-skills --skill instagram通过直接执行 curl 命令使用 Instagram Graph API 来读取和发布 Instagram 内容。
官方文档:
https://developers.facebook.com/docs/instagram-api
当您需要时,请使用此技能:
INSTAGRAM_ACCESS_TOKEN:一个长期有效的用户访问令牌INSTAGRAM_BUSINESS_ACCOUNT_ID:您的 Instagram 商业账户 ID广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
设置环境变量,例如:
export INSTAGRAM_ACCESS_TOKEN="EAAG..."
export INSTAGRAM_BUSINESS_ACCOUNT_ID="1784140xxxxxxx"
这些示例使用 Graph API 版本 v21.0。如果需要,您可以将其替换为最新版本。
根据您使用的端点,请确保您的应用已请求并获批(至少)以下权限:
instagram_basicpages_show_listinstagram_content_publish(用于发布媒体)instagram_manage_insights 及相关权限(用于洞察分析/某些话题标签用例)以下所有示例均假设您已设置:
INSTAGRAM_ACCESS_TOKEN
INSTAGRAM_BUSINESS_ACCOUNT_ID
获取账户最近的媒体内容(照片/视频/Reels):
curl -s -X GET "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media?fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
注意:
id:媒体 ID(后续用于获取详情/洞察分析)caption:标题文本media_type:IMAGE / VIDEO / CAROUSEL_ALBUMmedia_url:媒体的直接 URLpermalink:Instagram 永久链接timestamp:创建时间如果您已有一个媒体 id,可以获取更完整的信息。将 <your-media-id> 替换为“获取用户媒体”响应(上面第 1 节)中的 id 字段:
curl -s -X GET "https://graph.facebook.com/v21.0/<your-media-id>?fields=id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
注意:话题标签搜索需要符合 Facebook/Instagram 定义的适当商业用例和权限。请参考官方文档。
这通常涉及两个步骤:
将 <hashtag-name> 替换为您想要搜索的任何话题标签名称(不带 # 符号),例如 "travel"、"food"、"photography":
curl -s -X GET "https://graph.facebook.com/v21.0/ig_hashtag_search?user_id=$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)&q=<hashtag-name>" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
记下返回的 JSON 中的 id 字段,用于下一步。
将 <hashtag-id> 替换为“搜索话题标签”响应(上面第 3.1 节)中的 id 字段:
curl -s -X GET "https://graph.facebook.com/v21.0/<hashtag-id>/recent_media?user_id=$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)&fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
通过 Graph API 发布图片帖子通常需要两个步骤:
将请求数据写入 /tmp/request.json:
{
"image_url": "https://example.com/image.jpg",
"caption": "Hello from Instagram API 👋"
}
将 https://example.com/image.jpg 替换为任何可公开访问的图片 URL,并根据需要更新标题文本。
curl -s -X POST "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
响应将包含一个 id(媒体容器 ID),例如:
{
"id": "1790xxxxxxxxxxxx"
}
记下此 ID 用于下一步。
将请求数据写入 /tmp/request.json:
{
"creation_id": "<your-creation-id>"
}
将 <your-creation-id> 替换为“创建媒体容器”响应(上面第 4.1 节)中的 id 字段:
curl -s -X POST "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media_publish" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
如果成功,响应将包含最终的媒体 id:
{
"id": "1791yyyyyyyyyyyy"
}
然后,您可以使用“获取单个媒体的详细信息”命令来获取其 permalink。
(#10) Application does not have permission for this actionINSTAGRAM_ACCESS_TOKEN 是否是有效的长期令牌INSTAGRAM_ACCESS_TOKEN 是敏感信息;避免在日志或聊天记录中打印它v21.0 版本更新到最新<your-media-id> 这样的占位符文本,而不是在 URL 中使用 shell 变量,以避免依赖并使示例自成一体每周安装数
148
代码仓库
GitHub 星标数
47
首次出现
2026年1月24日
安全审计
安装于
opencode123
gemini-cli121
codex119
github-copilot116
cursor116
amp115
Use the Instagram Graph API by directly executing curl commands to read and publish Instagram content.
Official docs:
https://developers.facebook.com/docs/instagram-api
Use this skill when you need to:
INSTAGRAM_ACCESS_TOKEN: a long-lived user access tokenINSTAGRAM_BUSINESS_ACCOUNT_ID: your Instagram Business account IDSet the environment variables, for example:
export INSTAGRAM_ACCESS_TOKEN="EAAG..."
export INSTAGRAM_BUSINESS_ACCOUNT_ID="1784140xxxxxxx"
These examples use Graph API version v21.0. You can replace this with the latest version if needed.
Depending on which endpoints you use, make sure your app has requested and been approved for (at least):
instagram_basicpages_show_listinstagram_content_publish (for publishing media)instagram_manage_insights and related permissions (for insights / some hashtag use cases)All examples below assume you have already set:
INSTAGRAM_ACCESS_TOKEN
INSTAGRAM_BUSINESS_ACCOUNT_ID
Fetch the most recent media (photos / videos / Reels) for the account:
curl -s -X GET "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media?fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
Notes:
id: media ID (used for details / insights later)caption: caption textmedia_type: IMAGE / VIDEO / CAROUSEL_ALBUMmedia_url: direct URL to the mediapermalink: Instagram permalinktimestamp: creation timeIf you already have a media id, you can fetch more complete information. Replace <your-media-id> with the id field from the "Get User Media" response (section 1 above):
curl -s -X GET "https://graph.facebook.com/v21.0/<your-media-id>?fields=id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
Note: hashtag search requires proper business use cases and permissions as defined by Facebook/Instagram. Refer to the official docs.
This usually involves two steps:
Replace <hashtag-name> with any hashtag name you want to search for (without the # symbol), e.g., "travel", "food", "photography":
curl -s -X GET "https://graph.facebook.com/v21.0/ig_hashtag_search?user_id=$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)&q=<hashtag-name>" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
Note the id field in the returned JSON for use in the next step.
Replace <hashtag-id> with the id field from the "Search Hashtag" response (section 3.1 above):
curl -s -X GET "https://graph.facebook.com/v21.0/<hashtag-id>/recent_media?user_id=$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)&fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
Publishing an image post via the Graph API usually requires two steps :
Write the request data to /tmp/request.json:
{
"image_url": "https://example.com/image.jpg",
"caption": "Hello from Instagram API 👋"
}
Replace https://example.com/image.jpg with any publicly accessible image URL and update the caption text as needed.
curl -s -X POST "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
The response will contain an id (media container ID), for example:
{
"id": "1790xxxxxxxxxxxx"
}
Note this ID for use in the next step.
Write the request data to /tmp/request.json:
{
"creation_id": "<your-creation-id>"
}
Replace <your-creation-id> with the id field from the "Create Media Container" response (section 4.1 above):
curl -s -X POST "https://graph.facebook.com/v21.0/$(printenv INSTAGRAM_BUSINESS_ACCOUNT_ID)/media_publish" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $(printenv INSTAGRAM_ACCESS_TOKEN)"
If successful, the response will contain the final media id:
{
"id": "1791yyyyyyyyyyyy"
}
You can then use the "Get details for a single media" command to fetch its permalink.
(#10) Application does not have permission for this actionINSTAGRAM_ACCESS_TOKEN is a valid long-lived tokenINSTAGRAM_ACCESS_TOKEN is sensitive; avoid printing it in logs or chat transcriptsv21.0 version in URLs to the latest<your-media-id> instead of shell variables in URLs to avoid dependencies and make examples self-containedWeekly Installs
148
Repository
GitHub Stars
47
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode123
gemini-cli121
codex119
github-copilot116
cursor116
amp115
社交媒体内容策略指南:创建、优化与互动全流程 | 营销技能
39,000 周安装
软件架构评审指南:现代架构模式、分布式系统设计与云原生实践
437 周安装
Microsoft Dynamics 365 集成指南:使用 Membrane CLI 自动化 CRM/ERP 操作
431 周安装
Xquik X/Twitter 数据爬取与自动化API - 实时监控、批量提取、AI集成
439 周安装
Zoho CRM API 集成指南:使用 Membrane CLI 实现自动化销售与客户管理
434 周安装
Packer推送镜像到HCP注册表配置教程 - 自动化构建与CI/CD集成
441 周安装
AI 演示文稿生成器 | 一键创建专业幻灯片,支持 Marp 格式输出
440 周安装