---
suivi: 1369
date: 2026-08-31
sujet: meta_health_web
chantier: leads_marketing
type: diagnostic
statut: poussé
hash: 4fb6aa52
fichiers:
  - app/Services/MetaGraphService.php
  - app/Services/MetaGetCampaignDiagService.php
  - app/Http/Controllers/Admin/MetaGetCampaignDiagController.php
  - resources/js/Pages/Admin/Meta/GetCampaignDiag.vue
  - routes/web.php
  - tests/Feature/MetaGetCampaignDiagControllerTest.php
  - public/build/
  - docs/suivi/SUIVI_1369_meta_health_web.md
---

## PROMPT ENVOYÉ

PHASE 1 — DIAGNOSTIC CIBLÉ. Point web PHP-FPM pour savoir pourquoi `getCampaign()`
échoue depuis le 30/07 (acquis #1368). GS_ADMIN_ERP brut. Pas de fix ingestion /
rattrapage. Signaler programme_id NULL historique + multi-page #948.

## FICHES LUES

- **#1368** — cause isolée `getCampaign` ; CLI OVH Graph bloqué ; raw_payload OK ;
  mapping commercial peuplé ; programme_id jamais peuplé.
- Pattern GS_ADMIN_ERP brut : `MarcheDocumentSharePointResyncController`.
- Santé Meta existante : `/admin/meta/health` (lecture permission ; POST = GS_DSI).
  `/admin/meta-health` n’existe pas (404 Robin).

## SYNTHÈSE

### URL à ouvrir (Robin, connecté GS_ADMIN_ERP)

`https://envol.hectare.fr/admin/meta/get-campaign-diag`

(Route Laravel : `admin.meta.get-campaign-diag` — GET exécute le diagnostic immédiatement.)

Après `git pull` : **`php artisan route:clear`** obligatoire (nouvelle route).

### Ce que la page affiche

1. `/me?fields=id,name` — page du jeton + erreur Meta brute
2. `/debug_token` — scopes, **ads_read PRÉSENT/ABSENT** (central), expires_at
3. `getCampaign` sur `120257945104000093` (récent) et `120256761951820093` (dernier OK)
4. `getLead` sur le lead le plus récent en base
5. Contexte pages (config / jeton / leads 60 j) — signal #948
6. Note programme_id + lien `/admin/marketing/codes-campagnes` (UI permet déjà le Select programme)
7. Enregistrement d’une ligne `meta_health_checks` (table était vide)

Sécurité : jeton jamais exposé (suffixe 4 car. max) ; app_secret jamais affiché ;
accès `m365GroupNames()` brut GS_ADMIN_ERP.

### Hors lot (signalé)

- Rattrapage 106 leads : après cause connue.
- `programme_id` NULL historique = paramétrage mappings, pas régression getCampaign ;
  UI Codes campagnes OK pour renseigner.
- Multi-page #948 non construit ; live = META_PAGE_ACCESS_TOKEN seul.

## DÉPLOIEMENT-TEST

```bash
git pull origin main
php artisan route:clear
php artisan optimize:clear
php artisan view:clear
```

Ouvrir l’URL ci-dessus → coller le verdict (ads_read + messages getCampaign) dans le ticket.

## LEÇON

Ne pas confondre `/admin/meta-health` (inexistant) et `/admin/meta/health`. Un check
Graph Meta **doit** passer par PHP-FPM sur OVH cluster113. `ads_read` manquant sur un
jeton renouvelé explique getLead OK + getCampaign KO.
