Du kan finde en liste over tilgængelige endpoints her.
Brug af cURL
Eksempel på hvordan der søges på et CVR nummer. Husk at indsætte din licensekey og userid
<?php
// Define EAN API URL
$eanapi_url = 'https://eanapi.dk/v5/public/api/search/';
// Endpoint 'CVR'
$endpoint = 'cvr';
// Query for the CVR number '38584758'
$query = '38584758';
// Define licensekey and userid
$parameters = array(
'licensekey' => 'INSERT_LICENSE_KEY',
'userid' => 'INSERT_USER_ID',
);
// Build the URL for EAN API from the above variables
$query_url = $eanapi_url . $endpoint . '/' . $query . '?' . http_build_query( $parameters );
// Initialize cURL
$ch = curl_init();
// Define the URL to call
curl_setopt( $ch, CURLOPT_URL, $query_url );
// Let cURL know to return the JSON response
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
// Run the cURL
$response = curl_exec( $ch );
// Close cURL handler
curl_close($ch);
Brug af fopen / file_get_contents
<?php
// Define EAN API URL
$eanapi_url = 'https://eanapi.dk/v5/public/api/search/';
// Endpoint 'CVR'
$endpoint = 'cvr';
// Query for the CVR number '38584758'
$query = '38584758';
// Define licensekey and userid
$parameters = array(
'licensekey' => 'INSERT_LICENSE_KEY',
'userid' => 'INSERT_USER_ID',
);
// Build the URL for EAN API from the above variables
$query_url = $eanapi_url . $endpoint . '/' . $query . '?' . http_build_query( $parameters );
// Return the response
$response = file_get_contents( $query_url );
Brug af wp_remote_get (WordPress)
<?php
// Define EAN API URL
$eanapi_url = 'https://eanapi.dk/v5/public/api/search/';
// Endpoint 'CVR'
$endpoint = 'cvr';
// Query for the CVR number '38584758'
$query = '38584758';
// Define licensekey and userid
$parameters = array(
'licensekey' => 'INSERT_LICENSE_KEY',
'userid' => 'INSERT_USER_ID',
);
// Build the URL for EAN API from the above variables
$query_url = $eanapi_url . $endpoint . '/' . $query . '?' . http_build_query( $parameters );
// Return the response
$response = wp_remote_get( $query_url );