tomadmiraal
Verified User
I'm a user of the API of DA. The return data of DA by using the parse option can be f*cked up. Some values will be turned in to array-keys and that will change the value....
for example how to encrypt the vacation massages:
<?PHP
$data = "test=endday%3D%31%39%26endmonth%3D%30%38%26endtime%3Devening%26endyear%3D%32%30%30%38%26startday%3D%31%39%26startmonth%3D%30%38%26starttime%3Dmorning%26startyear%3D%32%30%30%38&test%2Etest=endday%3D%31%39%26endmonth%3D%30%38%26endtime%3Devening%26endyear%3D%32%30%30%38%26startday%3D%31%39%26startmonth%3D%30%38%26starttime%3Dmorning%26startyear%3D%32%30%30%38 ";
$data = urldecode($data);
preg_match_all('~(?<=^|&).(??!&[^&=]+=[^&=]+=[^&]+).)+~', $data, $matches);
for($i = 0; isset($matches[0][$i]); ++$i) {
$add = array(
'address' => strtok($matches[0][$i], '=')
);
$key = null;
while(false !== ($txt = strtok('=&'))) {
if($key) {
$add[$key] = $txt;
$key = null;
} else {
$key = $txt;
}
}
$result[] = $add;
}
?>
This is not really a nice way of programming... I sugest a new way of communication by using XML. This will secure a stable way of communication between the server and the API User.
Kind regards,
Tom Admiraal
for example how to encrypt the vacation massages:
<?PHP
$data = "test=endday%3D%31%39%26endmonth%3D%30%38%26endtime%3Devening%26endyear%3D%32%30%30%38%26startday%3D%31%39%26startmonth%3D%30%38%26starttime%3Dmorning%26startyear%3D%32%30%30%38&test%2Etest=endday%3D%31%39%26endmonth%3D%30%38%26endtime%3Devening%26endyear%3D%32%30%30%38%26startday%3D%31%39%26startmonth%3D%30%38%26starttime%3Dmorning%26startyear%3D%32%30%30%38 ";
$data = urldecode($data);
preg_match_all('~(?<=^|&).(??!&[^&=]+=[^&=]+=[^&]+).)+~', $data, $matches);
for($i = 0; isset($matches[0][$i]); ++$i) {
$add = array(
'address' => strtok($matches[0][$i], '=')
);
$key = null;
while(false !== ($txt = strtok('=&'))) {
if($key) {
$add[$key] = $txt;
$key = null;
} else {
$key = $txt;
}
}
$result[] = $add;
}
?>
This is not really a nice way of programming... I sugest a new way of communication by using XML. This will secure a stable way of communication between the server and the API User.
Kind regards,
Tom Admiraal
Last edited: