PHP Curl Create New Record
PHP Snippet to create a new record.
Be sure to update the API Keys and FIeld Slugs.
<?php
$tadabaseAppId = 'YOURAPPID';
$tadabaseApiKey = 'YOURAPIKEY';
$tadabaseApiSecret = 'YOURSECRET';
$tableId = 'TABLEID';
$url = 'https://api.tadabase.io/api/v1/';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url."data-tables/".$tableId."/records",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => urldecode(http_build_query(array(
'field_36' => 'TEST Curl', //Text
'field_37' => 'Some Pretty Long Text Some Pretty Long Text Some Pretty Long Text Some Pretty Long Text', //Long Text
'field_38' => '<h1>Rich Text</h1>', //Rich Text
'field_40' => 'moe@tadabase.io', //Email
'field_58' => 'tadabase.io', //Link
'field_43' => '100.1234', //Number
'field_44' => '999.99', //Currency
'field_42' => '8005551212', //Phone
'field_56' => '5', //Rating
'field_59' => '99', //Slider
'field_45' => '2020-11-14', //Date
'field_46' => '19:30:00', //Time
'field_47' => '2020-01-22 19:30:00', //Date and Time
'field_48[start]' => '2020-01-22 19:30:00', //Date Range Start
'field_48[end]' => '2020-01-22 21:30:00', //Date Range Start
'field_48[all_day]' => true, //Date Range Add Day
'field_39[title]' => 'Mr.',
'field_39[first_name]' => 'John',
'field_39[middle_name]' => 'C',
'field_39[last_name]' => 'Doe',
'field_41[address]' => '9048 Monte Mar',
'field_41[city]' => 'Los Angeles',
'field_41[state]' => 'CA',
'field_41[zip]' => '90035',
'field_49' => 'Checkbox', //Checkbox
'field_50' => 'radio1', //Radio
'field_51' => 'Select2', //Select
'field_53' => true, //Decision
'field_52' => array('multiselect1', 'multiselect2'), //Multi-Select
'field_61' => array('4MXQJdrZ6v', 'DVWQWRNZ49'), // Multi join
'field_62' => 'DVWQWRNZ49' // Single Join
))),
CURLOPT_HTTPHEADER => array(
"X-Tadabase-App-id: ".$tadabaseAppId,
"X-Tadabase-App-Key: ".$tadabaseApiKey,
"X-Tadabase-App-Secret: ".$tadabaseApiSecret ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
We'd love to hear your feedback.