QuincyAdam1
7 years agoQrew Trainee
Form Post API_ImportFromCSV Via PHP
Hello:
Does anyone have an example of submitting a form post API_ImportFromCSV via PHP?
We developed a scheduling form that successfully posts into QuickBase via Javascript, however, if you inspect the element, the user_token is available, which is a major security issue. We?ve solve this by creating a 2nd action page (ex. success.php), where we have this info in variables and handle the post from this page, however, we?re stuck with posting API_ImportFromCSV on this method.
To add context around the issue, we added a feature that allows us to schedule recurring appointments. The form looks like this:
On the form page, we have our submit function:
$('#live_form').attr('action', "/success.php).submit();
On our success.php page, we have:
$qb_base_url = "https://company.quickbase.com/db/";
$qb_stage_table2 = ?abcdefghij?;
$user_token = ?***********?;
$url = $qb_base_url . $qb_stage_table2 . "?act=API_AddRecord&usertoken=" . $user_token;
$data = array(
'_fid_7' => $_POST['_fid_7'], // DATEPICKER
'_fid_8' => $_POST['_fid_8'], // DATE FROM
'_fid_9' => $_POST['_fid_9'], // DATE TO
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'Content-Type' => 'application/xml',
'QUICKBASE-ACTION' => 'API_ImportFromCSV', // NOT SURE IF THIS IS CORRECT
'clist' => '7.8.9', // NOT SURE IF THIS IS CORRECT
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
This method will only submit 1 record, since we're not including the csvdata that successfully posts via JS. Is there a way to include this into the array to post as API_AdddRecord, or a better way to post API_ImportCSV? The javascript method w/out PHP is the only way we have successfully looped through and submitted multiple records.
Thoughts?
Thanks
Does anyone have an example of submitting a form post API_ImportFromCSV via PHP?
We developed a scheduling form that successfully posts into QuickBase via Javascript, however, if you inspect the element, the user_token is available, which is a major security issue. We?ve solve this by creating a 2nd action page (ex. success.php), where we have this info in variables and handle the post from this page, however, we?re stuck with posting API_ImportFromCSV on this method.
To add context around the issue, we added a feature that allows us to schedule recurring appointments. The form looks like this:
On the form page, we have our submit function:
$('#live_form').attr('action', "/success.php).submit();
On our success.php page, we have:
$qb_base_url = "https://company.quickbase.com/db/";
$qb_stage_table2 = ?abcdefghij?;
$user_token = ?***********?;
$url = $qb_base_url . $qb_stage_table2 . "?act=API_AddRecord&usertoken=" . $user_token;
$data = array(
'_fid_7' => $_POST['_fid_7'], // DATEPICKER
'_fid_8' => $_POST['_fid_8'], // DATE FROM
'_fid_9' => $_POST['_fid_9'], // DATE TO
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'Content-Type' => 'application/xml',
'QUICKBASE-ACTION' => 'API_ImportFromCSV', // NOT SURE IF THIS IS CORRECT
'clist' => '7.8.9', // NOT SURE IF THIS IS CORRECT
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
This method will only submit 1 record, since we're not including the csvdata that successfully posts via JS. Is there a way to include this into the array to post as API_AdddRecord, or a better way to post API_ImportCSV? The javascript method w/out PHP is the only way we have successfully looped through and submitted multiple records.
Thoughts?
Thanks