Authorization: Bearer YOUR_API_KEY
query {
contacts {
id
nr
first_name
last_name
company_name
email
phone_home
address {
street
city
zipcode
}
}
}
query {
project_matches {
id
project_nr
measure { # Gewerk
short
name
}
customer { # Kunde
id
first_name
last_name
email
}
contact { # Ansprechpartner
id
first_name
last_name
email
}
address { #Projektadresse
street
city
zipcode
}
current_project_match_status { # Projektstatus
status_code
name
}
}
}
query {
# Filter nach bestimmten IDs
project_matches(ids: [150798]) {
id
project_nr
customer_documents {
type
nr
value
created
file_upload {
url
}
}
histories {
custom_title
custom_text
created
}
}
}
query {
customer_documents {
id
created
nr
value
vat
status_code
document_type {
base_type
name
}
file_upload {
url
}
}
}
<?php
$url = 'https://login.hero-software.de/api/external/v7/graphql';
$apikey = 'YOUR_API_KEY'; // den API-Schlüssel bekommst du von unserem Support
// GraphQL-Query
$query = '
query ($category: CustomerCategoryEnum, $offset: Int) {
contacts(category: $category, orderBy: "id", offset: $offset) {
id
nr
last_name
email
modified
address {
street
city
zipcode
}
}
}
';
// Parameter für die Query
$variables = array(
"category" => "customer",
"offset" => 0,
);
$postdata = json_encode(array(
'query' => $query,
'variables' => $variables,
));
$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 (!empty($response['data'])) {
echo "Abgerufene Kontakte:";
var_dump($response['data']['contacts']);
} else {
echo "Ein Fehler ist aufgetreten:";
var_dump($response);
}
Noch Fragen?
Du hast noch Fragen zur HERO GraphQL API? Gern kannst du dich direkt an uns wenden. Hier findest du alle Kontaktmöglichkeiten.
Das könnte dich auch interessieren