PHP Get Records With Filters
<?php
$tadabaseAppId = 'APPID';
$tadabaseApiKey = 'APIKEY';
$tadabaseApiSecret = 'APISECRET';
$tableId = 'TABLEID';
function buildQuery ($arr) {
$conditions = http_build_query($arr);
return urldecode($conditions);
}
$arrQuery = array(
'filters' => array(
'items' => array(
array(
'field_id' => 'field_40',
'operator' => 'is',
'val' => 'test@tadabase.io'
),
array(
'field_id' => 'field_50',
'operator' => 'is',
'val' => 'radio1'
),
)
)
);
$conditions = buildQuery($arrQuery);
echo $conditions;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tadabase.io/api/v1/data-tables/".$tableId."/records?".$conditions,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"X-Tadabase-App-id: " . $tadabaseAppId,
"X-Tadabase-App-Key: " . $tadabaseApiKey,
"X-Tadabase-App-Secret: " . $tadabaseApiSecret
),
));
$response = array();
$response = curl_exec($curl);
curl_close($curl);
echo $response;
We'd love to hear your feedback.