- hash_hmac: documentation ( source)
- rawurlencode: documentation ( source)
- implode: documentation ( source)
- ksort: documentation ( source)
<?php
$api_key = '552542759d42133d1b37023c2baf36ca6871d006';
$now = new DateTime();
$url = "https://sellercenter-api.linio.com.mx/?";
$parameters = array(
'UserID' => 'john.doe@company.comd',
'Version' => '1.0',
'Action' => 'FeedList',
'Timestamp' => $now->format(DateTime::ISO8601),
);
// Sort parameters by name
ksort($parameters);
$params = array();
foreach ($parameters as $name => $value) {
$params[] = rawurlencode($name) . '=' . rawurlencode($value);
}
$strToSign = implode('&', $params);
// Compute signature and add it to the parameters
$parameters['Signature'] =
rawurlencode(hash_hmac('sha256', $strToSign, $api_key, false));
echo $parameters['Signature'];