@ 2014-03-13T09:13:29Z <?php
/**
* TME API - code snippet.
*
* More info at: https://developers.tme.eu
*/
if(!function_exists('hash_hmac'))
function hash_hmac($algo, $data, $key, $raw_output = false)
{
$algo = strtolower($algo);
$pack = 'H'.strlen($algo('test'));
$size = 64;
$opad = str_repeat(chr(0x5C), $size);
$ipad = str_repeat(chr(0x36), $size);
if (strlen($key) > $size) {
$key = str_pad(pack($pack, $algo($key)), $size, chr(0x00));
} else {
$key = str_pad($key, $size, chr(0x00));
}
for ($i = 0; $i < strlen($key) - 1; $i++) {
$opad[$i] = $opad[$i] ^ $key[$i];
$ipad[$i] = $ipad[$i] ^ $key[$i];
}
$output = $algo($opad.pack($pack, $algo($ipad.$data)));
return ($raw_output) ? pack($pack, $output) : $output;
}
ini_set('display_errors', 1);
error_reporting(E_ALL);
$token = 'b050bd709a43eecc443820c022b6774ca703ddb216b6f6765f';//'<put_your_token_here>';
$app_secret = '5656847466f0e5d08577';//<put_your_app_secret_here>';
$params = array(
'SymbolList' => array('1N4007'),
'Country' => 'PL',
'Currency' => 'PLN',
'Language' => 'PL',
);
$response = api_call('Products/GetPrices', $params, $token, $app_secret, true);
$result = json_decode($response, true);
var_dump(PHP_VERSION);
echo '<pre>';
print_r($result);
echo '</pre>';
//---------------------------------------------------------
function api_call($action, $params, $token, $app_secret, $show_header=false)
{
$api_url = 'https://api.tme.eu/' . $action . '.json';
// calculate HMAC-SHA1 signature
$params['Token'] = $token;
ksort($params);
// In PHP 5.4 http_build_query() offers enc_type parameter (PHP_QUERY_RFC3986) which replaces bellow snippet.
$encoded_params = str_replace(
array('+', '%7E'),
array('%20', '~'),
http_build_query($params)
);
$signature_base = 'POST' . '&' . rawurlencode($api_url) . '&' . rawurlencode($encoded_params);
$api_signature = base64_encode(hash_hmac('sha1', $signature_base, $app_secret, true));
$params['ApiSignature'] = $api_signature;
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
);
return file_get_contents($api_url, false, stream_context_create($opts));
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.4.26 0.393 0.037 19.13 5.4.25 0.410 0.047 19.21 5.4.24 0.397 0.033 19.20 5.4.23 0.387 0.037 19.23 5.4.22 0.387 0.037 18.98 5.4.21 0.387 0.043 19.04 5.4.20 0.380 0.037 18.94 5.4.19 0.430 0.037 18.92 5.4.18 0.420 0.047 19.21 5.4.17 0.343 0.040 19.20 5.4.16 0.350 0.027 19.04 5.4.15 0.373 0.037 19.02 5.4.14 0.373 0.033 16.45 5.4.13 0.343 0.037 16.34 5.4.12 0.363 0.033 16.35 5.4.11 0.357 0.033 16.39 5.4.10 0.357 0.037 16.57 5.4.9 0.390 0.023 16.25 5.4.8 0.397 0.030 16.46 5.4.7 0.357 0.040 16.22 5.4.6 0.387 0.037 16.32 5.4.5 0.373 0.040 16.45 5.4.4 0.377 0.040 16.58 5.4.3 0.387 0.033 16.22 5.4.2 0.397 0.030 16.50 5.4.1 0.390 0.037 16.46 5.4.0 0.387 0.037 15.95 5.3.28 0.387 0.037 14.57 5.3.27 0.420 0.043 14.54 5.3.26 0.360 0.040 14.63 5.3.25 0.337 0.037 14.70 5.3.24 0.340 0.037 14.54 5.3.23 0.337 0.030 14.61 5.3.22 0.333 0.033 14.45 5.3.21 0.317 0.040 14.66 5.3.20 0.367 0.037 14.53 5.3.19 0.397 0.033 14.46 5.3.18 0.387 0.037 14.35 5.3.17 0.367 0.037 14.52 5.3.16 0.397 0.027 14.39 5.3.15 0.403 0.033 14.49 5.3.14 0.367 0.043 14.43 5.3.13 0.373 0.040 14.48 5.3.12 0.377 0.043 14.49 5.3.11 0.390 0.040 14.34 5.3.10 0.383 0.027 13.97 5.3.9 0.393 0.037 13.99 5.3.8 0.383 0.040 13.83 5.3.7 0.380 0.043 13.83 5.3.6 0.417 0.037 13.82 5.3.5 0.393 0.037 13.87 5.3.4 0.350 0.043 13.78 5.3.3 0.387 0.030 13.72 5.3.2 0.383 0.037 13.78 5.3.1 0.383 0.037 13.59 5.3.0 0.397 0.033 13.59
preferences:dark mode live preview
147.31 ms | 1394 KiB | 7 Q