Get a list of campaigns
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
$request_url = 'https://api.frontcore.com/v2/campaigns';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-API-Key: {your-api-key}',
'Accept: application/json',
));
$result = curl_exec($ch);
curl_close($ch);
If the method is successful it responds with an JSON structure, as it is shown below.
[
{
"active": false,
"campaign_code": null,
"courses": [
62765
],
"currency": "nok",
"customers": [],
"discount_type": "Percent",
"discount_value": 12,
"expired": true,
"id": 1265,
"is_archived": false,
"running": false,
"tags": [],
"title": "My campaign",
"type": "Campaign",
"uses_code": false,
"waiting": false
},
{
"active": true,
"campaign_code": null,
"courses": [],
"currency": "nok",
"customers": [
121704
],
"discount_type": "Value",
"discount_value": 100,
"expired": true,
"id": 1463,
"is_archived": false,
"running": false,
"tags": [],
"title": null,
"type": "Agreement",
"uses_code": false,
"waiting": false
}
]
Unsuccessful response sample:
{
"error": "Wrong API Key"
}