Skip to main content

Data samples

You'll find here PHP code samples.​

If cURL doesn't actually work in your environment, this could help you to install it.​

Here is an example to make an advanced research on the data of a form​


<?php

$formId;
// Initialisation of the request
$curl = curl_init();

// Definition of request's headers
curl_setopt_array($curl, array(
CURLOPT_URL => "https://forms.kizeo.com/rest/v3/forms/' . $formId . '/data/advanced",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
// Filters to apply in request's body
CURLOPT_POSTFIELDS => "{\n \"global_filters\": \"\",\n \"filters\": [\n {\n \"field\": \"field_name\",\n \"operator\": \"comparison_operator\",\n \"type\": \"simple\",\n \"val\": \"compare_value\"\n }\n ],\n \"order\": [\n {\n \"col\": \"order_data\",\n \"type\": \"col_type\"\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: YOUR_TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));

// Send request and show response
$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

How to save data without saving form​


<?php

$formId;
// Initialisation of the request
$curl = curl_init();

// Definition of request's headers
curl_setopt_array($curl, array(
CURLOPT_URL => "https://forms.kizeo.com/rest/v3/forms/' . $formId . '/data/push",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
// Parameters in request's body
CURLOPT_POSTFIELDS => "{\n \"recipient_user_id\": \"integer\",\n \"fields\": {\n \"field_id\": {\n \"value\": \"string\"\n }\n }\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: YOUR_TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));

// Send request and show response
$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

You'll find here Java code samples.​

Here is an example to make an advanced research on the data of a form​


string formId;
// Initialisation of the request
OkHttpClient client = new OkHttpClient();

// Definition of the request's headers and body
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"global_filters\": \"\",\r\n \"filters\": [\r\n {\r\n \"field\": \"field_name\",\r\n \"operator\": \"comparison_operator\",\r\n \"type\": \"simple\",\r\n \"val\": \"compare_value\"\r\n }\r\n ],\r\n \"order\": [\r\n {\r\n \"col\": \"order_data\", \r\n \"type\": \"col_type\"\r\n }\r\n ]\r\n}");

Request request = new Request.Builder()
.url("https://forms.kizeo.com/rest/v3/forms/".formId."/data/advanced")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("Authorization", "YOUR_TOKEN")
.addHeader("cache-control", "no-cache")
.build();

// Send request
Response response = client.newCall(request).execute();

How to save data without saving form​


string formId;
// Initialisation of the request
OkHttpClient client = new OkHttpClient();

// Definition of the request's headers and body
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"recipient_user_id\": \"integer\",\r\n \"fields\": {\r\n \"field_id\": {\r\n \"value\": \"string\"\r\n }\r\n }\r\n}");

Request request = new Request.Builder()
.url("https://forms.kizeo.com/rest/v3/forms/".formId."/push")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("Authorization", "YOUR_TOKEN")
.addHeader("cache-control", "no-cache")
.build();

// Send request
Response response = client.newCall(request).execute();

You'll find here Javascript code samples.​

Here is an example to make an advanced research on the data of a form​


var formId;
// Initialisation of the request and headers' definition
var settings = {
"async": true,
"crossDomain": true,
"url": "https://forms.kizeo.com/rest/v3/forms/" . formId . "/data/advanced",
"method": "POST",
"headers": {
"content-type": "application/json",
"Authorization": "YOUR_TOKEN",
"cache-control": "no-cache",
},
// Definition of filters to apply
"processData": false,
"data": "{\r\n \"global_filters\": \"\",\r\n \"filters\": [\r\n {\r\n \"field\": \"field_name\",\r\n \"operator\": \"comparison_operator\",\r\n \"type\": \"simple\",\r\n \"val\": \"compare_value\"\r\n }\r\n ],\r\n \"order\": [\r\n {\r\n \"col\": \"order_data\",\r\n \"type\": \"col_type\"\r\n }\r\n ]\r\n}"
}

// Send request and show response
$.ajax(settings).done(function (response) {
console.log(response);
});

How to save data without saving form​


var formId;
// Initialisation of the request and headers' definition
var settings = {
"async": true,
"crossDomain": true,
"url": "https://forms.kizeo.com/rest/v3/forms/" . formId . "/push",
"method": "POST",
"headers": {
"content-type": "application/json",
"Authorization": "YOUR_TOKEN",
"cache-control": "no-cache",
},
// Definition of filters to apply
"processData": false,
"data": "{\r\n \"recipient_user_id\": \"integer\",\r\n \"fields\": {\r\n \"field_id\": {\r\n \"value\": \"string\"\r\n }\r\n }\r\n}"
}

// Send request and show response
$.ajax(settings).done(function (response) {
console.log(response);
});