mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-20 21:14:04 +00:00
43 lines
1006 B
PHP
43 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Classes\General;
|
|
|
|
|
|
class WePostHelper
|
|
{
|
|
|
|
/**
|
|
* @param string $clientId
|
|
* @param string $clientSecrent
|
|
* @param string $type
|
|
* @return string
|
|
*/
|
|
static function generateSignature(string $clientId, string $clientSecrent, string $type){
|
|
// public parameters
|
|
$timestamp = 1234; //time();
|
|
|
|
$params = [
|
|
'client_id' => $clientId,
|
|
'type' => $type,
|
|
'timestamp' => $timestamp
|
|
];
|
|
|
|
// $businessParams = [
|
|
// 'test1' => '1',
|
|
// ];
|
|
|
|
ksort($params);
|
|
$str = '';
|
|
foreach ($params as $key => $value) {
|
|
if(is_array($value)) {
|
|
$str .= $key.json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
continue;
|
|
}
|
|
$str .= $key. $value;
|
|
}
|
|
$str = $clientSecrent.$str.$clientSecrent;
|
|
$signature = strtoupper(md5($str));
|
|
return $signature;
|
|
}
|
|
}
|