New: EspoCRM API naar formulier bedrijf aanmelden

This commit is contained in:
2026-01-29 10:13:54 +01:00
parent a1af2e4928
commit aa98cd394e
5 changed files with 275 additions and 137 deletions

28
static/prefill.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// prefill.php
$apiKey = '31b69c04fc1944c905bcf895789c1c98';
$crmBaseUrl = 'https://crm.start-it.nl/api/v1/Account/';
$id = $_GET['id'] ?? '';
if (!$id || !preg_match('/^[a-z0-9]+$/', $id)) {
http_response_code(400);
die(json_encode(['error' => 'Invalid ID']));
}
$opts = [
"http" => [
"method" => "GET",
"header" => "X-Api-Key: $apiKey\r\nContent-Type: application/json\r\n"
]
];
$context = stream_context_create($opts);
$response = @file_get_contents($crmBaseUrl . $id, false, $context);
if ($response === false) {
http_response_code(404);
echo json_encode(['error' => 'CRM record not found']);
} else {
header('Content-Type: application/json');
echo $response;
}