← back to Goldleafwallpaper

scripts/ig-poster/CONNECT.md

54 lines

# @goldleafwallpaper Instagram poster — connect card

**Status:** BUILT + running every 4h in **DRY-RUN**. It posts nothing until the
account is connected. The moment the two env vars below exist, the *same*
scheduled job goes LIVE automatically at the next tick — one switch, no code change.

## What it does
- Posts **one new RML SKU every 4 hours** (00/04/08/12/16/20) to @goldleafwallpaper.
- Rotates through all 61 `RML-` patterns in `data/products.json`, then cycles.
- Each post = the product's Shopify image + an info caption (motif · colorway ·
  "trade source · free memo samples" · link-in-bio · rotating hashtags).
- Advances the cursor only on success; a failed post retries the same SKU next tick.
- Cost: **$0** — Meta Graph publishing is free.

## One-time setup (only you can do this — needs a Meta login)
Instagram allows automated posting **only** via the Meta Graph API, which requires:

1. **Convert @goldleafwallpaper to a Business (or Creator) account** in the IG app:
   Settings → Account type → Switch to professional → Business.
2. **Link it to a Facebook Page** (create a "Gold Leaf Wallpaper" Page if none):
   IG app → Settings → Business → connect the Page.
3. In **developers.facebook.com** → your app (reuse the DW/Norma app or make one) →
   add the Instagram Graph API product, and generate a **long-lived Page access
   token** with `instagram_basic` + `instagram_content_publish` + `pages_show_list`.
4. Get the **IG user-id**: `GET /me/accounts` → your Page → `GET /{page-id}?fields=instagram_business_account`.

> Prefer to hand it off? Reply "run the Meta connect" and I'll drive the whole
> portal with the `portal-driver` skill after your single Meta login, and capture
> the token + IG user-id for you.

## Flip it live
Drop the two values into `scripts/ig-poster/.env` (gitignored) — or better, route
them through the `secrets` skill so they're stored canonically:

```
GOLDLEAF_IG_TOKEN=<long-lived page token>
GOLDLEAF_IG_USER_ID=<ig business account id>
```

Then confirm the next run posts for real:

```
cd ~/Projects/goldleafwallpaper && node scripts/ig-poster/post-next.js
```

A `LIVE` line + `POSTED ✓ media_id …` means it's live. To force a dry preview any
time: `DRY_RUN=1 node scripts/ig-poster/post-next.js`.

## Operate
- Log: `~/.claude/logs/goldleaf-ig-poster.log` (launchd) and `data/ig/post-log.jsonl`.
- Pause: `launchctl bootout gui/$(id -u)/com.steve.goldleaf-ig-poster`
- Resume: `launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.steve.goldleaf-ig-poster.plist`
- Reset rotation to SKU #1: `rm data/ig/queue-state.json`