<?php
$url = 'https://login.hero-software.de/api/v1/Projects/create';
$apikey = 'YOUR_API_KEY'; // den API-Schlüssel bekommst du von unserem Support
$data = array(
"measure" => "PRJ",
"customer" => array(
"email" => "max.mustermann@example.org",
"title" => "Herr",
"first_name" => "Max",
"last_name" => "Mustermann",
"company_name" => "Meine Firma",
),
"address" => array(
"street" => "Schwarzer Bär 2",
"city" => "Hannover",
"zipcode" => "30449",
"country_code" => "DE",
),
"projectaddress" => array(
"street" => "Schwarzer Bär 5",
"city" => "Hannover",
"zipcode" => "30449",
"country_code" => "DE",
),
"project_match" => array(
"comment" => "Dieser Kommentar erscheint im Logbuch zu dem Projekt.",
"partner_notes" => "Optionale Hinweise für das Notizfeld.",
"partner_source" => "Mein Kontaktformular",
),
);
$postdata = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer '.$apikey,
));
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result, true);
if (isset($response['status']) && $response['status'] == 'success') {
echo "Projekt erfolgreich angelegt";
} else {
echo "Ein Fehler ist aufgetreten: ".$response['message']."
\n";
var_dump($response);
}