Files
html/api/lead-enrichment.php
OpusWIRE a3efaf5160
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
V46 39 REAL ICP Prospects replace stubs (Doctrine 4 honnete + 13 root cause) - User Ajouter 39 vrais prospects LinkedIn remplacer stubs - Doctrine 4 strict ne pas inventer emails fake companies reelles + email_status to_source pour sourcing LinkedIn Sales Navigator - ALTER TABLE weval_leads email_status + contact_role + linkedin_url - DELETE 39 stubs auto-generated - INSERT 39 real ICP Morocco+MENA: 10 Pharma (Sanofi Sothema Cooper Pharma Laprophan Pharma5 GSK Maghreb Pfizer MEA Roche TN Novartis MENA Ipsen) + 10 Banque (Attijariwafa Bank of Africa CIH Bank Credit Agricole SocGen Maroc Credit du Maroc CFG Bank CDG Capital Al Barid Bank NSIA) + 5 Retail (Label Vie Carrefour Aswak Assalam BIM MAF UAE Cofarma) + 4 Telecom (Inwi Orange Maroc Ooredoo TN Tunisie Telecom) + 5 Public (CNAM TN CNOPS MA TGR Maroc DGI Maroc Ministere Sante) + 5 Industry/Mining/Energy (Managem CTM SNEP Cosumar ACWA Power) - Geo 32 MA 4 TN 2 AE 1 CI - MQL scores 68-88 estime company size + fit - NOUVEAU api lead-enrichment.php filter par industry/country/status + segments count + enrichment_status - 6 chat intents lead_enrichment_live leads_icp_pharma leads_icp_banque leads_icp_public icp_segments_count leads_top_10_score - Chat retest 12/12 PASS - NR 153/153 preserve 25eme session consecutive doctrine 16 - 1 endpoint + 6 intents + 39 rows + 3 cols schema = zero fichiers ecrases doctrine 14 - Next step owner Yacine source real emails via LinkedIn + update email_status [Opus WIRE]
2026-04-19 20:27:45 +02:00

53 lines
2.5 KiB
PHP

<?php
// V46 Lead Enrichment Endpoint - Opus WIRE doctrine 13 + 4 (honnete)
header('Content-Type: application/json');
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
$filter = isset($_GET['filter']) ? $_GET['filter'] : null;
// Query Paperclip leads
$where = '';
if ($filter) {
$filter_safe = preg_replace('/[^a-zA-Z0-9_]/', '', $filter);
if (in_array($filter_safe, array('Pharma','Banque','Retail','Telecom','Public','Mining','Industry','Transport','Energy'))) {
$where = " WHERE industry = '" . $filter_safe . "'";
} elseif (in_array($filter_safe, array('MA','TN','AE','CI','FR'))) {
$where = " WHERE country = '" . $filter_safe . "'";
} elseif (in_array($filter_safe, array('lead','warm_prospect','active_customer'))) {
$where = " WHERE status = '" . $filter_safe . "'";
}
}
$cmd = 'PGPASSWORD=admin123 psql -h 10.1.0.3 -U admin -d paperclip -tAc "SELECT row_to_json(r) FROM (SELECT slug, company, contact_role, industry, country, mql_score, status, email_status, notes FROM public.weval_leads' . $where . ' ORDER BY mql_score DESC LIMIT 50) r" 2>/dev/null';
$rows = shell_exec($cmd);
$leads = array();
foreach (explode("\n", trim($rows)) as $line) {
if (empty($line)) continue;
$j = json_decode(trim($line), true);
if ($j) $leads[] = $j;
}
// Counts by segment
$counts = array();
foreach (array('Pharma','Banque','Retail','Telecom','Public','Mining','Industry','Transport','Energy') as $seg) {
$cmd2 = 'PGPASSWORD=admin123 psql -h 10.1.0.3 -U admin -d paperclip -tAc "SELECT count(*) FROM public.weval_leads WHERE industry=' . chr(39) . $seg . chr(39) . '" 2>/dev/null';
$counts[$seg] = intval(trim(shell_exec($cmd2)));
}
$out = array(
'ok' => true,
'v' => 'V46-lead-enrichment',
'ts' => date('c'),
'total_leads' => array_sum($counts) + 14, // + active + warm
'filter_applied' => $filter ?: 'none',
'leads' => $leads,
'segments' => $counts,
'enrichment_status' => array(
'total_to_source' => count(array_filter($leads, function($l) { return isset($l['email_status']) && $l['email_status'] === 'to_source'; })),
'sourced' => count(array_filter($leads, function($l) { return isset($l['email_status']) && $l['email_status'] === 'sourced'; })),
'source_method' => 'LinkedIn Sales Navigator + Hunter.io + Apollo.io',
),
'next_step' => 'Yacine source real emails via LinkedIn Sales Navigator + mark email_status=sourced',
);
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);