· 5 years ago · Oct 21, 2020, 02:00 PM
1/**
2* $system_id - your project system ID (number)
3* $version - callback or API version
4* $args - array with API method or callback parameters. API parameters list you can find in API method description
5* $system_key - your system key
6*/
7function getSignature($system_id, $version, array $args, $system_key){
8 $md5 = array();
9 $md5[] = $system_id;
10 $md5[] = $version;
11 foreach ($args as $required_arg) {
12 $arg = $required_arg;
13 if(is_array($arg)){
14 if(count($arg)) {
15 $recursive_arg = '';
16 array_walk_recursive($arg, function($item) use (& $recursive_arg) { if(!is_array($item)) { $recursive_arg .= ($item . ':');} });
17 $md5[] = substr($recursive_arg, 0, strlen($recursive_arg)-1); // get rid of last colon-sign
18 } else {
19 $md5[] = '';
20 }
21 } else {
22 $md5[] = $arg;
23 }
24 };
25 $md5[] = $system_key;
26 $md5_str = implode('*', $md5);
27 $md5 = md5($md5_str);
28 return $md5;
29}