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)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qq54E
function name:  (null)
number of ops:  22
compiled vars:  !0 = $token, !1 = $app_secret, !2 = $params, !3 = $response, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'b050bd709a43eecc443820c022b6774ca703ddb216b6f6765f'
    9     1        ASSIGN                                                   !1, '5656847466f0e5d08577'
   10     2        ASSIGN                                                   !2, <array>
   17     3        INIT_FCALL_BY_NAME                                       'api_call'
          4        SEND_VAL_EX                                              'Products%2FGetPrices'
          5        SEND_VAR_EX                                              !2
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        SEND_VAL_EX                                              <true>
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   18    11        INIT_FCALL                                               'json_decode'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !4, $10
   20    16        ECHO                                                     '%3Cpre%3E'
   21    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   22    20        ECHO                                                     '%3C%2Fpre%3E'
   54    21      > RETURN                                                   1

Function api_call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qq54E
function name:  api_call
number of ops:  62
compiled vars:  !0 = $action, !1 = $params, !2 = $token, !3 = $app_secret, !4 = $show_header, !5 = $api_url, !6 = $encoded_params, !7 = $signature_base, !8 = $api_signature, !9 = $opts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV_INIT                                        !4      <false>
   28     5        CONCAT                                           ~10     'https%3A%2F%2Fapi.tme.eu%2F', !0
          6        CONCAT                                           ~11     ~10, '.json'
          7        ASSIGN                                                   !5, ~11
   31     8        ASSIGN_DIM                                               !1, 'Token'
          9        OP_DATA                                                  !2
   32    10        INIT_FCALL                                               'ksort'
         11        SEND_REF                                                 !1
         12        DO_ICALL                                                 
   35    13        INIT_FCALL                                               'str_replace'
   36    14        SEND_VAL                                                 <array>
   37    15        SEND_VAL                                                 <array>
   38    16        INIT_FCALL                                               'http_build_query'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $15     
         19        SEND_VAR                                                 $15
         20        DO_ICALL                                         $16     
   35    21        ASSIGN                                                   !6, $16
   40    22        INIT_FCALL                                               'rawurlencode'
         23        SEND_VAR                                                 !5
         24        DO_ICALL                                         $18     
         25        CONCAT                                           ~19     'POST%26', $18
         26        CONCAT                                           ~20     ~19, '%26'
         27        INIT_FCALL                                               'rawurlencode'
         28        SEND_VAR                                                 !6
         29        DO_ICALL                                         $21     
         30        CONCAT                                           ~22     ~20, $21
         31        ASSIGN                                                   !7, ~22
   41    32        INIT_FCALL                                               'base64_encode'
         33        INIT_FCALL                                               'hash_hmac'
         34        SEND_VAL                                                 'sha1'
         35        SEND_VAR                                                 !7
         36        SEND_VAR                                                 !3
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $24     
         39        SEND_VAR                                                 $24
         40        DO_ICALL                                         $25     
         41        ASSIGN                                                   !8, $25
   43    42        ASSIGN_DIM                                               !1, 'ApiSignature'
         43        OP_DATA                                                  !8
   47    44        INIT_ARRAY                                       ~28     'POST', 'method'
   48    45        ADD_ARRAY_ELEMENT                                ~28     'Content-type%3A+application%2Fx-www-form-urlencoded', 'header'
   49    46        INIT_FCALL                                               'http_build_query'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                         $29     
         49        ADD_ARRAY_ELEMENT                                ~28     $29, 'content'
         50        INIT_ARRAY                                       ~30     ~28, 'http'
   45    51        ASSIGN                                                   !9, ~30
   53    52        INIT_FCALL                                               'file_get_contents'
         53        SEND_VAR                                                 !5
         54        SEND_VAL                                                 <false>
         55        INIT_FCALL                                               'stream_context_create'
         56        SEND_VAR                                                 !9
         57        DO_ICALL                                         $32     
         58        SEND_VAR                                                 $32
         59        DO_ICALL                                         $33     
         60      > RETURN                                                   $33
   54    61*     > RETURN                                                   null

End of function api_call

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.56 ms | 1400 KiB | 33 Q