3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * TME API - code snippet. * * More info at: https://developers.tme.eu */ $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); 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)); }
Output for 5.4.34 - 5.4.40, 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 5.6.28, 7.0.0 - 7.0.3, 7.0.5 - 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/Qq54E on line 53 <pre></pre>
Output for 5.4.41 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19, 7.0.4
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/Qq54E on line 53 <pre></pre>
Output for hhvm-3.10.0 - 3.12.0
Warning: Failed to open https://api.tme.eu/Products/GetPrices.json (Could not resolve host: api.tme.eu) in /in/Qq54E on line 53 <pre></pre>
Output for 5.3.0 - 5.4.32
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: No such file or directory in /in/Qq54E on line 53 <pre></pre>
Output for 5.2.0 - 5.2.17
Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: No such file or directory in /in/Qq54E on line 53 <pre></pre>
Output for 5.1.2 - 5.1.6
Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: No such file or directory in /in/Qq54E on line 53 Fatal error: Call to undefined function json_decode() in /in/Qq54E on line 18
Process exited with code 255.
Output for 5.0.0 - 5.1.1
Fatal error: Call to undefined function hash_hmac() in /in/Qq54E on line 41
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: http_build_query() in /in/Qq54E on line 38
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: http_build_query() in /in/Qq54E on line 38
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: http_build_query() in /in/Qq54E on line 38