3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
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(): open_basedir restriction in effect. File(https://api.tme.eu/Products/GetPrices.json) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): Failed to open stream: Operation not permitted in /in/Qq54E on line 53 <pre></pre>
Output for 8.0.13
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.3.0 - 5.3.29, 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.33
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.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.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(): open_basedir restriction in effect. File(https://api.tme.eu/Products/GetPrices.json) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Qq54E on line 53 Warning: file_get_contents(https://api.tme.eu/Products/GetPrices.json): failed to open stream: Operation not permitted 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.0.5, 5.1.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.3.11, 4.4.0 - 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

preferences:
290.42 ms | 401 KiB | 456 Q