# Instagram Integration — Implementation Guide

> A complete, copy‑to‑another‑project reference for how Instagram is wired into this Laravel app:
> the **embedded / OAuth login**, the **Meta permissions (scopes)** that are requested, the
> **incoming‑message webhook**, **outgoing message sending**, and how to use a **Meta test account**
> to verify incoming + outgoing Instagram messages.
>
> Everything below is taken from the live code. File paths and the key snippets are quoted so you can
> replicate the feature in a different project without re‑reverse‑engineering it.

---

## 1. High‑level architecture

Instagram messaging in this app is built on top of the **Facebook Graph API** (Instagram does **not**
have a separate login here — an Instagram Business account is reached *through* a connected Facebook
Page). Two cooperating pieces:

| Concern | Where it lives |
|---|---|
| OAuth "login" / connect flow | `app/Traits/InstagramAccountTrait.php` + `app/Http/Controllers/Client/AccountsController.php` |
| Manual token connect / verify / sync | `app/Addons/OmniSync/Repository/Instagram/InstagramSettingRepository.php` |
| Incoming messages (webhook) | `app/Addons/OmniSync/Controllers/Webhook/MessengerWebhookController.php` → `app/Addons/OmniSync/Repository/Webhook/MessengerRepository.php` |
| Outgoing messages (DM send) | `app/Addons/OmniSync/Traits/MessengerTrait.php` |
| Content publishing (feed posts) | `app/Traits/InstagramAccountTrait.php` (`instagramFeed`, `instagramUploadMedia`) |
| Settings / credentials | `settings` table (read via `setting('key')`) |
| Routes | `app/Addons/OmniSync/routes.php` |

> **Important:** the *messaging* features (inbox, DM send, bot reply, webhook) live inside the
> **OmniSync addon** and are gated behind `addon_is_activated('omnisync')` **and** the client's
> subscription having `instagram_access`. The basic *connect + content publish* lives in core
> (`app/Traits/InstagramAccountTrait.php`). Keep that split in mind when porting.

---

## 2. Meta App setup & required permissions (scopes)

### 2.1 App credentials (settings table)

These keys are read everywhere via the `setting()` helper. Instagram falls back to the Facebook
credentials if its own are empty.

| Setting key | Purpose |
|---|---|
| `instagram_client_id` | Meta App ID (falls back to `facebook_client_id`) |
| `instagram_client_secret` | Meta App Secret (falls back to `facebook_client_secret`) |
| `instagram_app_version` | Graph API version, e.g. `v25.0` (falls back to `facebook_app_version`, default `v25.0`) |
| `is_instagram_activated` | Master on/off toggle for the Instagram connect button |
| `meta_app_id` | App ID used by the JS SDK embedded‑signup popup (see §4.2) |
| `meta_configuration_id` | Facebook Login *Configuration ID* for the embedded‑signup popup |

Credential resolution (`app/Traits/InstagramAccountTrait.php:34`):

```php
private function instagramAppCredentials(): array
{
    return [
        'client_id'     => setting('instagram_client_id') ?: setting('facebook_client_id'),
        'client_secret' => setting('instagram_client_secret') ?: setting('facebook_client_secret'),
    ];
}
```

API version normalization (`app/Traits/InstagramAccountTrait.php:15`) — accepts `25`, `v25`, `v25.0`
and always returns a `vNN.0` string; defaults to `v25.0`.

### 2.2 Permissions / scopes requested

These are the exact scopes asked for during the OAuth login
(`app/Traits/InstagramAccountTrait.php:42`):

**Always requested (base scopes):**

| Scope | Why |
|---|---|
| `instagram_basic` | Read basic IG account/profile info |
| `instagram_content_publish` | Publish feed posts / carousels |
| `instagram_manage_insights` | Read IG insights/metrics |
| `pages_show_list` | List the user's Facebook Pages (IG is reached via a Page) |
| `pages_read_engagement` | Read Page engagement |
| `business_management` | Manage business assets |

**Added only when OmniSync is active AND the subscription has `instagram_access`** (i.e. the messaging
add‑on) — this is what unlocks **DMs**:

| Scope | Why |
|---|---|
| `instagram_manage_messages` | Send & receive Instagram Direct Messages |
| `pages_messaging` | Messaging through the connected Page |

```php
public function instagramAuthUrl(): string
{
    $scopes = [
        'instagram_basic',
        'instagram_content_publish',
        'instagram_manage_insights',
        'pages_show_list',
        'pages_read_engagement',
        'business_management',
    ];

    if (addon_is_activated('omnisync') && auth()->user()->client->activeSubscription?->instagram_access) {
        $scopes = array_merge($scopes, [
            'instagram_manage_messages',
            'pages_messaging',
        ]);
    }
    // ...builds the dialog URL (see §3.1)
}
```

> **For the embedded JS‑SDK popup (WhatsApp‑style, see §4.2)** the scope string is set directly in the
> `FB.login(...)` call. For an Instagram popup you would request
> `instagram_basic, instagram_manage_messages, pages_messaging, pages_show_list, business_management`.

### 2.3 Meta App Dashboard config you must create

To replicate in another project, in the Meta App dashboard:

1. **Products:** add *Facebook Login* and *Instagram Graph API* (Messenger product for IG messaging).
2. **Facebook Login → Settings → Valid OAuth Redirect URIs:** add your callback
   `https://YOUR_DOMAIN/{locale}/client/accounts/callback/instagram`
   (route name `client.accounts.callback`, param `plat_form=instagram`).
3. **App Roles:** add Instagram **Testers** and Facebook **Testers/Developers** for dev‑mode testing
   (see §7).
4. **Webhooks → Instagram object:** subscribe to the `messages` (and optionally `messaging_postbacks`,
   `comments`) fields, with the callback URL + verify token from §5.
5. **Permissions:** the scopes in §2.2 require **App Review** before they work for non‑role users in
   production. In development mode they work for users with a role on the app.

---

## 3. The OAuth ("embedded") login flow — server‑side redirect

This is the primary connect flow used in‑app: a server‑side redirect to Meta's OAuth dialog, then a
callback that exchanges the `code` for tokens and saves the connected accounts.

### 3.1 Step 1 — build the auth URL & redirect

`AccountsController::create()` (`app/Http/Controllers/Client/AccountsController.php:66`) maps the
platform to its auth URL and redirects:

```php
$url = match ($data['plat_form']) {
    'facebook'  => setting('is_facebook_activated') ? $this->facebookAuthUrl() : null,
    'instagram' => setting('is_instagram_activated') ? $this->instagramAuthUrl() : null,
    // ...
};
if (! $url) { abort(403); }
return redirect($url);
```

The Instagram URL (`app/Traits/InstagramAccountTrait.php:64`):

```php
return sprintf(
    'https://www.facebook.com/%s/dialog/oauth?client_id=%s&redirect_uri=%s&scope=%s&response_type=code&state=%s',
    $version,
    urlencode($credentials['client_id']),
    urlencode(route('client.accounts.callback', ['plat_form' => 'instagram'])),
    $scope,                         // comma-separated scopes from §2.2
    urlencode(csrf_token())         // state = CSRF token
);
```

### 3.2 Step 2 — callback exchanges code → tokens → pages

`AccountsController::callback()` (`app/Http/Controllers/Client/AccountsController.php:86`), Instagram
branch:

```php
$oauth_access_token = $this->instagramAccessToken($request->code);   // short-lived
$access_token       = $oauth_access_token['access_token'];

$longLived = $this->instagramLongLivedToken($access_token);          // long-lived
if (! empty($longLived['access_token'])) {
    $access_token = $longLived['access_token'];
}

$pages = $this->instagramPages($access_token);                       // user's Pages + linked IG
// ...error / empty handling...
$this->saveinstagramPages($pages);                                  // persist accounts + client setting
```

**Token exchange endpoints** (all GET on `graph.facebook.com`):

| Step | Endpoint | Key params |
|---|---|---|
| Code → short‑lived token | `/{version}/oauth/access_token` | `client_id`, `client_secret`, `redirect_uri`, `code` |
| Short → long‑lived token | `/{version}/oauth/access_token` | `grant_type=fb_exchange_token`, `client_id`, `client_secret`, `fb_exchange_token` |
| List pages + IG | `/{version}/me/accounts?fields=id,name,access_token,instagram_business_account,connected_instagram_account&limit=100` | `access_token` |

(`instagramAccessToken` `:74`, `instagramLongLivedToken` `:102`, `instagramPages` `:118`.)

### 3.3 Step 3 — persist connected accounts

`saveinstagramPages()` (`app/Traits/InstagramAccountTrait.php:142`):

- Resolves the IG business account id from each Page via
  `instagram_business_account.id` → fallback `connected_instagram_account.id`
  (`resolveInstagramBusinessAccountId` `:129`).
- Fetches the IG profile:
  `/{version}/{ig_account_id}?fields=id,username,name,profile_picture_url&access_token={PAGE_TOKEN}`.
- Inserts a row into **`social_accounts`** with `details = 'instagram'`, storing the **Page access token**
  (`token`), `account_id` (IG id), name and profile image.
- If OmniSync + `instagram_access`: also upserts a **`client_settings`** row of
  `type = instagram` via `syncInstagramClientSettingFromAccount()` (`:209`) — this is what the
  messaging/webhook code reads later (`business_account_id`, `access_token`, `is_connected`).

> **Key insight when porting:** the token saved for messaging is the **Page access token** returned
> from `/me/accounts`, not the user token. DMs are sent/received against the Page that owns the IG
> business account.

---

## 4. Alternative connect methods

### 4.1 Manual token paste + verify (no OAuth)

`InstagramSettingRepository::instagramSettingUpdate()`
(`app/Addons/OmniSync/Repository/Instagram/InstagramSettingRepository.php:41`) lets a client paste an
access token directly. It validates the token with Meta's **debug_token** endpoint and stores the
returned metadata:

```php
$url = 'https://graph.facebook.com/debug_token?input_token=' . $accessToken . '&access_token=' . $accessToken;
// ...curl GET...
if ($responseData['data']['is_valid'] === true) {
    $is_connected   = 1;
    $token_verified = 1;
    $scopes         = $responseData['data']['scopes'];   // <-- granted scopes are read back here
}
```

It then saves a `client_settings` row (`type = instagram`) with `scopes`, `granular_scopes`,
`app_id`, `fb_user_id`, `expires_at`, `data_access_expires_at`, and resolves the IG business account
id via `getPageInfo()` (`:222`):

```php
$url = 'https://graph.facebook.com/v22.0/me?fields=instagram_business_account,name&access_token=' . $accessToken;
// stores business_account_id (IG id) + business_account_name
```

**Sync** (`instagramSync` `:126`) re‑runs `debug_token` to refresh validity/scopes/expiry. This is the
in‑app "is my connection still good?" check — useful when **testing** (see §7).

Routes for these (`app/Addons/OmniSync/routes.php:58`):

```
GET    client/instagram-settings                 → instagram.settings
POST   client/instagram/settings/update          → instagram.settings.update
POST   client/instagram-settings/sync/{id}       → instagram-settings.sync
POST   client/instagram/settings/remove-token/{id} → instagram.remove-token
```

### 4.2 Embedded‑signup popup (Facebook JS SDK) — reference pattern

The app already ships a true **embedded signup** popup for WhatsApp in
`app/Addons/EmbeddedSignup/views/index.blade.php`. It is the cleanest template if you want a
**popup‑based embedded login for Instagram** instead of the full‑page redirect in §3. The mechanics:

1. Load the SDK: `https://connect.facebook.net/en_US/sdk.js` and init with your app id:

   ```js
   window.fbAsyncInit = function () {
       FB.init({ appId: "{{ setting('meta_app_id') }}", autoLogAppEvents: true, xfbml: true, version: 'v20.0' });
   };
   ```

2. Launch login with a **Configuration ID** and `response_type: 'code'`:

   ```js
   FB.login(fbLoginCallback, {
       config_id: metaConfigurationId,        // setting('meta_configuration_id')
       response_type: 'code',
       override_default_response_type: true,
       scope: "business_management, whatsapp_business_management, whatsapp_business_messaging", // ← swap for IG scopes
       extras: { setup: {}, featureType: '', sessionInfoVersion: '3' }
   });
   ```

   For Instagram, replace the `scope` string with the IG scopes from §2.2, e.g.
   `"instagram_basic, instagram_manage_messages, pages_messaging, pages_show_list, business_management"`,
   and create a matching **Instagram** Facebook‑Login configuration in the Meta dashboard to get its
   `config_id`.

3. The popup posts a `code` back; `fbLoginCallback` ships `{ code, ... }` to the server, which exchanges
   it for a token (same exchange as §3.2) and stores it. (For WhatsApp the server side is
   `app/Addons/EmbeddedSignup/Repository/EmbeddedSignupRepository.php` — `getAccessClient()` does the
   `/{version}/oauth/access_token?...&code=...` exchange, `validateAccessToken()` calls `debug_token`.)

> To port the popup approach to Instagram: reuse the JS in `EmbeddedSignup/views/index.blade.php`, swap
> the scopes + `config_id`, and on the server reuse `instagramAccessToken()` for the code→token
> exchange and `instagramSettingUpdate()`/`saveinstagramPages()` for persistence. **Do not modify the
> existing WhatsApp EmbeddedSignup addon** — copy the pattern.

---

## 5. Incoming Instagram messages (webhook)

Instagram and Messenger share **one** webhook endpoint. Instagram is distinguished by the top‑level
`object === 'instagram'` field in the payload.

### 5.1 Routes (`app/Addons/OmniSync/routes.php:18`)

```php
Route::get('messenger/webhook/{token}',  [MessengerWebhookController::class, 'verifyToken'])->name('messenger.verify.token');
Route::post('messenger/webhook/{token}', [MessengerWebhookController::class, 'receiveResponse'])->name('messenger.webhook');
```

`{token}` is the client's `webhook_verify_token` — this is how a multi‑tenant install routes an
incoming event to the correct client.

### 5.2 Verification handshake (`MessengerRepository::verifyToken` `:48`)

Meta sends a GET with `hub.mode`, `hub.verify_token`, `hub.challenge`. The code matches the verify
token against a `Client`, flips `messengerSetting.webhook_verified = 1`, and echoes the challenge:

```php
$client = $this->clientModel->where('webhook_verify_token', $hubVerifyToken)->with('messengerSetting')->first();
if (!empty($client) && !empty($client->webhook_verify_token)) {
    if ($hubMode === 'subscribe') {
        // mark verified...
        return response($hubChallenge, 200)->header('Content-Type', 'text/plain');
    }
    return response()->json([], 403);
}
```

### 5.3 Receiving messages (`MessengerRepository::receiveResponse` `:109`)

```php
$entry        = $request->entry[0] ?? null;
$value        = $entry['messaging'][0] ?? null;
$pageID       = $entry['id'] ?? null;
$instagramObj = $request->object ?? null;          // 'instagram' for IG
$isInstagram  = $instagramObj === 'instagram';

$client = $this->resolveWebhookClient($token, $pageID, $isInstagram);
// guard: client exists, has webhook_verify_token, active subscription, channel access
if (isset($value['message'])) {
    $this->handleIncomingMessage($value, $client, $instagramObj);
} elseif (isset($value['postback'])) {
    $this->handlePostback($value, $client);
}
```

Notes when porting:

- **Channel access gate:** `subscriptionHasChannelAccess()` (`:172`) checks the subscription has the
  Instagram (or Messenger) feature before processing.
- **Stored message:** persisted to `messages` with
  `source = $isInstagram ? TypeEnum::INSTAGRAM : TypeEnum::MESSENGER` (`:846`), the Meta `mid` as
  `message_id`, text/attachments mapped to `value` / `header_image|audio|video|document`, and
  `is_contact_msg = 1` for inbound.
- **Sender profile:** the contact's name/avatar are fetched from
  `/{version}/{senderId}?fields=name,profile_pic&access_token={IG_TOKEN}`.
- **Message deletion:** IG sends `message.is_deleted`; the code deletes the local row (`:745`).
- **Echo:** outbound echoes (`is_echo`) are stored with `is_contact_msg = 0`.

---

## 6. Sending Instagram messages (DMs)

Outgoing DMs go through the **same Graph API Send API** as Messenger, in
`app/Addons/OmniSync/Traits/MessengerTrait.php`.

- **Endpoint:** `POST {graphApiUrl}/me/messages?access_token={TOKEN}`
- **Token selection:** Instagram vs Messenger is detected per‑message; IG uses
  `getClientInstagramAccessToken($client)` (the Page token stored on the `instagram` client setting),
  Messenger uses `getClientMessengerAccessToken($client)`.
- **Recipient:** `{ recipient: { id: <IG user id> }, message: { ... } }`.

Payload shapes (all under `message`):

| Type | Body |
|---|---|
| Text | `message: { text }` |
| Image / Audio / Video / File | `message: { attachment: { type: 'image'\|'audio'\|'video'\|'file', payload: { url } } }` |
| Buttons | `message: { attachment: { type: 'template', payload: { template_type: 'button', text, buttons: [{ type: 'postback', title, payload }] } } }` |

On success the Meta `message_id` is stored and status set to `SENT`; on failure the error is stored and
status set to `FAILED`.

> **24‑hour messaging window:** Instagram (like Messenger) only allows free‑form DMs within 24h of the
> user's last message. Outside that window only specific message tags are allowed — relevant when
> testing outbound sends.

---

## 7. Testing with a Meta **test account** (incoming + outgoing)

Because the messaging scopes (`instagram_manage_messages`, `pages_messaging`) require App Review for
public users, you test against accounts that have a **role on the app** while it is in *Development*
mode. Two complementary layers:

### 7.1 Meta‑side setup (so a test IG account can send/receive)

1. **App in Development mode** (default for a new app). Role‑holders bypass App Review.
2. **Add an Instagram Tester:** Meta App Dashboard → *App Roles → Roles* (or *Instagram → API setup
   with Instagram login → add Instagram testers*). Enter the IG username of your test account and
   **accept the invite** from inside Instagram (Settings → Apps and Websites → Tester Invites).
3. **Test Instagram Business/Creator account:** the IG account must be a **Business** or **Creator**
   account and **linked to a Facebook Page** you administer (DMs require the Page link).
4. **Add the Page + IG account** during the OAuth connect (§3) using a Facebook user that has a role on
   the app and admin rights on the Page.
5. **Subscribe the webhook** (Meta dashboard → *Webhooks → Instagram*) to the `messages` field, using
   the callback URL `…/messenger/webhook/{client_webhook_verify_token}` and the same verify token.
   The app also programmatically subscribes the Page/app to the IG account during connect.

### 7.2 In‑app verification (does the connection actually work?)

- **Token validity / scopes:** open *Instagram Settings* and hit **Sync**
  (`instagram-settings.sync` → `InstagramSettingRepository::instagramSync`). It calls `debug_token`
  and refreshes `is_connected`, `token_verified`, `scopes`, `expires_at`. If a scope is missing here,
  the test account didn't grant it — re‑run the OAuth consent in §3.
- **Incoming test:** from the **test Instagram account**, send a DM to the connected IG business
  account. Watch `storage/logs/laravel.log` and confirm a row appears in `messages` with
  `source = instagram`, `is_contact_msg = 1`, and a new `contacts` row (`type = instagram`). If
  nothing arrives, re‑check: webhook verified (`messenger.verify.token` returned the challenge),
  the `messages` field subscribed, and the IG account is a tester.
- **Outgoing test:** reply from the app inbox (or trigger a bot reply). It POSTs to `/me/messages`
  (§6). A `200` with a `message_id` confirms send; a `FAILED` status with an error usually means the
  **24h window** has closed or the `instagram_manage_messages` scope is missing.
- **Demo server guard:** several write paths short‑circuit when `isDemoMode()` is true — make sure
  your test environment is **not** in demo mode or sends/sync will be disabled.

### 7.3 Quick test checklist

- [ ] App in Development mode, test FB user has a role
- [ ] Test IG account is Business/Creator, linked to a Page, accepted Tester invite
- [ ] OAuth connect completed; `social_accounts.details = instagram` row exists with a Page token
- [ ] `client_settings` row `type = instagram` has `business_account_id` + `access_token`
- [ ] Sync shows `is_valid = true` and lists `instagram_manage_messages`, `pages_messaging`
- [ ] Webhook verified + subscribed to `messages`
- [ ] Inbound DM creates a `messages` row (`source = instagram`)
- [ ] Outbound reply returns a `message_id` (within 24h window)

---

## 8. Database & models

| Table / Model | Role for Instagram |
|---|---|
| `social_accounts` (`App\Models\SocialAccount`) | One row per connected IG account; `details = 'instagram'`, `account_id` = IG business id, `token` = Page access token, `image`, `name`. |
| `client_settings` (`App\Models\ClientSetting`) | One row `type = instagram` per client: `access_token`, `business_account_id`, `business_account_name`, `scopes`, `granular_scopes`, `is_connected`, `token_verified`, `expires_at`, `data_access_expires_at`, `fb_user_id`, `app_id`. Read by the webhook + send code. |
| `messages` (`App\Models\Message`) | `source = TypeEnum::INSTAGRAM`; `message_id`, `value`, `header_*` media, `buttons`, `status`, `is_contact_msg`. |
| `contacts` (`App\Models\Contact`) | `type = TypeEnum::INSTAGRAM`; IG user id, name, profile image. |
| `plans` / `subscriptions` | `instagram_access` flag gates messaging features. |
| `users` | `instagram_access` permission. |

Relevant migrations (search `*instagram*` in `database/migrations/`):

```
add_instagram_type_to_client_setting_table
add_instagram_type_to_contact_table
add_instagram_type_to_messages_table
add_instagram_access_to_plans_table
add_instagram_access_to_subscriptions_table
add_instagram_access_permission_to_permissions_column_in_users_table
```

`TypeEnum::INSTAGRAM` is the enum value used across `source` / `type` columns.

---

## 9. Helper functions (`app/Helpers/Helper.php`)

```php
function getClientInstagramAccessToken($client) {
    if ($client) {
        $client->loadMissing('instagramSetting');
        if ($client->instagramSetting && !empty($client->instagramSetting->access_token)) {
            return $client->instagramSetting->access_token;
        }
    }
    return null;
}

function facebookGraphApiVersion(): string { /* normalizes setting('instagram_app_version') ?: setting('facebook_app_version','v25.0') */ }
function facebookGraphApiUrl(string $path = ''): string {
    return 'https://graph.facebook.com/'.facebookGraphApiVersion().'/'.$path;
}
```

`addon_is_activated('omnisync')` gates all messaging features. `setting('key')` reads the credentials.

---

## 10. Porting checklist (to your other project)

1. **Settings:** add the `settings` keys in §2.1 (and an admin UI to edit them).
2. **Scopes/permissions:** request the scopes in §2.2 — base set always, messaging set behind your
   add‑on / plan flag. Submit them for **App Review** before production.
3. **OAuth:** copy `InstagramAccountTrait` (`instagramAuthUrl`, `instagramAccessToken`,
   `instagramLongLivedToken`, `instagramPages`, `saveinstagramPages`,
   `resolveInstagramBusinessAccountId`) + the `callback` branch in `AccountsController`. Register the
   redirect URI in the Meta dashboard.
4. **(Optional) Embedded popup:** copy the JS‑SDK pattern from
   `EmbeddedSignup/views/index.blade.php`, swap scopes + a Facebook‑Login `config_id` for Instagram.
5. **Persistence:** create the `social_accounts` + `client_settings (type=instagram)` rows; store the
   **Page token**.
6. **Webhook:** copy `messenger/webhook/{token}` (verify + receive), detect `object === 'instagram'`,
   store messages with `source = instagram`, subscribe the `messages` field in the dashboard.
7. **Send:** copy `MessengerTrait` send logic; POST to `/me/messages` with the IG Page token; honor the
   24h window.
8. **DB:** add the `instagram` enum value to `client_settings.type`, `contacts.type`, `messages.source`
   and the `instagram_access` flags on plans/subscriptions/users.
9. **Test:** follow §7 with a tester IG (Business/Creator) account + Page in a Development‑mode app.

---

### Key files index

| File | Lines of interest |
|---|---|
| `app/Traits/InstagramAccountTrait.php` | OAuth 42–127, save 142–228, publish 230–360 |
| `app/Http/Controllers/Client/AccountsController.php` | create 66–84, callback 86–167 |
| `app/Addons/OmniSync/Repository/Instagram/InstagramSettingRepository.php` | token verify/update 41–122, sync 126–197, page info 222–255 |
| `app/Addons/OmniSync/Controllers/Webhook/MessengerWebhookController.php` | 18–26 |
| `app/Addons/OmniSync/Repository/Webhook/MessengerRepository.php` | verify 48–72, receive 109–170, IG detect 120/539/745/846 |
| `app/Addons/OmniSync/Traits/MessengerTrait.php` | send logic |
| `app/Addons/EmbeddedSignup/views/index.blade.php` | JS‑SDK embedded‑signup popup pattern |
| `app/Addons/OmniSync/routes.php` | webhook 18–19, IG routes 57–82 |
| `app/Helpers/Helper.php` | `getClientInstagramAccessToken`, `facebookGraphApiUrl` |
</content>
</invoke>
