๐ŸŽ Get the FREE AI Skills Starter Guide โ€” Subscribe โ†’
BytesAgainBytesAgain
๐Ÿฆ€ ClawHub

Instagram Api

by @lifeissea

Post to Instagram (Feed, Story, Reels, Carousel) and Threads using the official Meta Graph API. Requires Imgur for media hosting.

Versionv1.1.1
Downloads2,712
Installs8
TERMINAL
clawhub install instagram-api

๐Ÿ“– About This Skill


name: Instagram API description: Post to Instagram (Feed, Story, Reels, Carousel) and Threads using the official Meta Graph API. Requires Imgur for media hosting. version: 1.1.1 author: raon requires_env: - INSTAGRAM_ACCESS_TOKEN - INSTAGRAM_BUSINESS_ACCOUNT_ID - IMGUR_CLIENT_ID

instagram-api

Meta Graph API๋ฅผ ์‚ฌ์šฉํ•ด Instagram๊ณผ Threads์— ์ง์ ‘ ํฌ์ŠคํŒ…ํ•˜๋Š” ์Šคํ‚ฌ. ๋ฏธ๋””์–ด ํ˜ธ์ŠคํŒ…์€ Imgur API๋ฅผ ์‚ฌ์šฉ (์ด๋ฏธ์ง€/์˜์ƒ ๊ณต๊ฐœ URL ์ƒ์„ฑ).


Imgur Client ID ๋ฐœ๊ธ‰

Instagram Graph API๋Š” ๊ณต๊ฐœ URL๋กœ๋งŒ ๋ฏธ๋””์–ด๋ฅผ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ์–ด Imgur๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

1. https://api.imgur.com/oauth2/addclient ์ ‘์† 2. Application name: ์›ํ•˜๋Š” ์ด๋ฆ„ (์˜ˆ: raon-instagram) 3. Authorization type: Anonymous usage without user authorization ์„ ํƒ 4. Authorization callback URL: https://localhost (Anonymous์ด๋ฏ€๋กœ ํ˜•์‹๋งŒ ๋งž์ถ”๋ฉด ๋จ) 5. ์ด๋ฉ”์ผ ์ž…๋ ฅ ํ›„ ์ œ์ถœ โ†’ Client ID ํ™•์ธ 6. ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •:

   export IMGUR_CLIENT_ID="your_client_id_here"
   


ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •

# ~/.openclaw/.env ๋˜๋Š” ~/.zshrc์— ์ถ”๊ฐ€
export INSTAGRAM_ACCESS_TOKEN="your_token_here"
export INSTAGRAM_BUSINESS_ACCOUNT_ID="your_account_id_here"

Threads (์„ ํƒ)

export THREADS_ACCESS_TOKEN="your_threads_token_here" export THREADS_USER_ID="your_threads_user_id_here"

Imgur (์ด๋ฏธ์ง€ ํ˜ธ์ŠคํŒ…์šฉ โ€” ํ”ผ๋“œ/๋ฆด์Šค ์—…๋กœ๋“œ ์‹œ ํ•„์š”)

export IMGUR_CLIENT_ID="your_imgur_client_id_here"


Meta Graph API ํ† ํฐ ๋ฐœ๊ธ‰

1. Meta for Developers ์ ‘์† 2. ์•ฑ ์ƒ์„ฑ โ†’ Business ์œ ํ˜• ์„ ํƒ 3. Instagram Graph API ์ œํ’ˆ ์ถ”๊ฐ€ 4. ๊ถŒํ•œ ์š”์ฒญ: - instagram_basic - instagram_content_publish - pages_read_engagement 5. Access Token ๋ฐœ๊ธ‰: - Graph API Explorer: https://developers.facebook.com/tools/explorer/ - ์žฅ๊ธฐ ํ† ํฐ(Long-lived token)์œผ๋กœ ๊ตํ™˜: 60์ผ ์œ ํšจ 6. Business Account ID ํ™•์ธ:

   curl "https://graph.facebook.com/v21.0/me/accounts?access_token=YOUR_TOKEN"
   

> ๐Ÿ’ก Imgur Client ID: https://api.imgur.com/oauth2/addclient (Anonymous usage ์„ ํƒ)


์Šคํฌ๋ฆฝํŠธ ์‚ฌ์šฉ๋ฒ•

ํ”ผ๋“œ ํฌ์ŠคํŒ…

bash scripts/post-feed.sh <์ด๋ฏธ์ง€๊ฒฝ๋กœ> <์บก์…˜ํŒŒ์ผ>

์˜ˆ์‹œ

bash scripts/post-feed.sh ./photo.jpg ./caption.txt

์Šคํ† ๋ฆฌ ํฌ์ŠคํŒ…

bash scripts/post-story.sh <์ด๋ฏธ์ง€๊ฒฝ๋กœ>

์˜ˆ์‹œ

bash scripts/post-story.sh ./story.jpg

๋ฆด์Šค ํฌ์ŠคํŒ…

bash scripts/post-reels.sh <์˜์ƒ๊ฒฝ๋กœ> <์บก์…˜ํŒŒ์ผ>

์˜ˆ์‹œ

bash scripts/post-reels.sh ./reel.mp4 ./caption.txt

์บ๋Ÿฌ์…€ ํฌ์ŠคํŒ…

bash scripts/post-carousel.sh <์บก์…˜ํŒŒ์ผ> <์ด๋ฏธ์ง€1> <์ด๋ฏธ์ง€2> [์ด๋ฏธ์ง€3...]

์˜ˆ์‹œ

bash scripts/post-carousel.sh ./caption.txt ./img1.jpg ./img2.jpg ./img3.jpg

Threads ํฌ์ŠคํŒ…

bash scripts/post-threads.sh <์บก์…˜ํŒŒ์ผ> [์ด๋ฏธ์ง€URL]

์˜ˆ์‹œ (ํ…์ŠคํŠธ๋งŒ)

bash scripts/post-threads.sh ./caption.txt

์˜ˆ์‹œ (์ด๋ฏธ์ง€ ํฌํ•จ)

bash scripts/post-threads.sh ./caption.txt "https://example.com/image.jpg"


ํŒŒ์ผ ๊ตฌ์กฐ

instagram-api/
โ”œโ”€โ”€ SKILL.md                    # ์ด ํŒŒ์ผ
โ””โ”€โ”€ scripts/
    โ”œโ”€โ”€ post-feed.sh            # ํ”ผ๋“œ ํฌ์ŠคํŒ…
    โ”œโ”€โ”€ post-story.sh           # ์Šคํ† ๋ฆฌ ํฌ์ŠคํŒ…
    โ”œโ”€โ”€ post-reels.sh           # ๋ฆด์Šค ํฌ์ŠคํŒ…
    โ”œโ”€โ”€ post-carousel.sh        # ์บ๋Ÿฌ์…€ ํฌ์ŠคํŒ…
    โ””โ”€โ”€ post-threads.sh         # Threads ํฌ์ŠคํŒ…


์ฃผ์˜์‚ฌํ•ญ

  • Instagram์€ ๊ณต๊ฐœ URL๋กœ๋งŒ ๋ฏธ๋””์–ด ์—…๋กœ๋“œ ๊ฐ€๋Šฅ (๋กœ์ปฌ ํŒŒ์ผ ์ง์ ‘ ์—…๋กœ๋“œ ๋ถˆ๊ฐ€)
  • ์ด ์Šคํ‚ฌ์€ Imgur๋ฅผ ํ†ตํ•ด ์ž„์‹œ ๊ณต๊ฐœ URL ์ƒ์„ฑ
  • ๋ฆด์Šค ๋™์˜์ƒ ์ฒ˜๋ฆฌ์—๋Š” ์ˆ˜๋ถ„ ์†Œ์š”๋  ์ˆ˜ ์žˆ์Œ
  • API ํ˜ธ์ถœ ์‹คํŒจ ์‹œ ~/logs/sns/ ๋กœ๊ทธ ํ™•์ธ