New: EspoCRM API naar formulier bedrijf aanmelden
This commit is contained in:
28
static/prefill.php
Normal file
28
static/prefill.php
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user