3v4l.org

run code in 300+ PHP versions simultaneously
<?php function btce_query($method, array $req = array()) { // API settings $key = 'OCM7MMKC-6NZGJD3U-9CA6UZQK-XD4FQEJT-1RJWY7MV'; // your API-key $secret = '867ebdf127a2d0aff48dad5363fb558addd25d12a640e564d3396b7356434b5e'; // your Secret-key $req['method'] = $method; $mt = explode(' ', microtime()); $req['nonce'] = $mt[1]; // generate the POST data string $post_data = http_build_query($req, '', '&'); $sign = hash_hmac('sha512', $post_data, $secret); // generate the extra headers $headers = array( 'Sign: '.$sign, 'Key: '.$key, ); // our curl handle (initialize if required) static $ch = null; if (is_null($ch)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; BTCE PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); } curl_setopt($ch, CURLOPT_URL, 'https://btc-e.com/tapi/'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // run the query $res = curl_exec($ch); if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch)); $dec = json_decode($res, true); if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists'); return $dec; } $result = btce_query('getInfo'); //$result = btce_query('Trade', array('pair' => 'btc_usd', 'type' => 'buy', 'amount' => 1, 'rate' => 10)); //buy 1 BTC @ 10 USD var_dump($result); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rtkJr
function name:  (null)
number of ops:  8
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'btce_query'
          1        SEND_VAL                                                 'getInfo'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   45     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   46     7      > RETURN                                                   1

Function btce_query:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 60
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 90, Position 2 = 98
Branch analysis from position: 90
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 105, Position 2 = 109
Branch analysis from position: 105
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 109
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
filename:       /in/rtkJr
function name:  btce_query
number of ops:  111
compiled vars:  !0 = $method, !1 = $req, !2 = $key, !3 = $secret, !4 = $mt, !5 = $post_data, !6 = $sign, !7 = $headers, !8 = $ch, !9 = $res, !10 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    4     2        ASSIGN                                                   !2, 'OCM7MMKC-6NZGJD3U-9CA6UZQK-XD4FQEJT-1RJWY7MV'
    5     3        ASSIGN                                                   !3, '867ebdf127a2d0aff48dad5363fb558addd25d12a640e564d3396b7356434b5e'
    7     4        ASSIGN_DIM                                               !1, 'method'
          5        OP_DATA                                                  !0
    8     6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '+'
          8        INIT_FCALL                                               'microtime'
          9        DO_ICALL                                         $14     
         10        SEND_VAR                                                 $14
         11        DO_ICALL                                         $15     
         12        ASSIGN                                                   !4, $15
    9    13        FETCH_DIM_R                                      ~18     !4, 1
         14        ASSIGN_DIM                                               !1, 'nonce'
         15        OP_DATA                                                  ~18
   12    16        INIT_FCALL                                               'http_build_query'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 ''
         19        SEND_VAL                                                 '%26'
         20        DO_ICALL                                         $19     
         21        ASSIGN                                                   !5, $19
   14    22        INIT_FCALL                                               'hash_hmac'
         23        SEND_VAL                                                 'sha512'
         24        SEND_VAR                                                 !5
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $21     
         27        ASSIGN                                                   !6, $21
   18    28        CONCAT                                           ~23     'Sign%3A+', !6
         29        INIT_ARRAY                                       ~24     ~23
   19    30        CONCAT                                           ~25     'Key%3A+', !2
         31        ADD_ARRAY_ELEMENT                                ~24     ~25
   17    32        ASSIGN                                                   !7, ~24
   23    33        BIND_STATIC                                              !8
   24    34        TYPE_CHECK                                    2          !8
         35      > JMPZ                                                     ~27, ->60
   25    36    >   INIT_FCALL_BY_NAME                                       'curl_init'
         37        DO_FCALL                                      0  $28     
         38        ASSIGN                                                   !8, $28
   26    39        INIT_FCALL_BY_NAME                                       'curl_setopt'
         40        SEND_VAR_EX                                              !8
         41        FETCH_CONSTANT                                   ~30     'CURLOPT_RETURNTRANSFER'
         42        SEND_VAL_EX                                              ~30
         43        SEND_VAL_EX                                              <true>
         44        DO_FCALL                                      0          
   27    45        INIT_FCALL_BY_NAME                                       'curl_setopt'
         46        SEND_VAR_EX                                              !8
         47        FETCH_CONSTANT                                   ~32     'CURLOPT_USERAGENT'
         48        SEND_VAL_EX                                              ~32
         49        INIT_FCALL                                               'php_uname'
         50        SEND_VAL                                                 's'
         51        DO_ICALL                                         $33     
         52        CONCAT                                           ~34     'Mozilla%2F4.0+%28compatible%3B+BTCE+PHP+client%3B+', $33
         53        CONCAT                                           ~35     ~34, '%3B+PHP%2F'
         54        INIT_FCALL                                               'phpversion'
         55        DO_ICALL                                         $36     
         56        CONCAT                                           ~37     ~35, $36
         57        CONCAT                                           ~38     ~37, '%29'
         58        SEND_VAL_EX                                              ~38
         59        DO_FCALL                                      0          
   29    60    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         61        SEND_VAR_EX                                              !8
         62        FETCH_CONSTANT                                   ~40     'CURLOPT_URL'
         63        SEND_VAL_EX                                              ~40
         64        SEND_VAL_EX                                              'https%3A%2F%2Fbtc-e.com%2Ftapi%2F'
         65        DO_FCALL                                      0          
   30    66        INIT_FCALL_BY_NAME                                       'curl_setopt'
         67        SEND_VAR_EX                                              !8
         68        FETCH_CONSTANT                                   ~42     'CURLOPT_POSTFIELDS'
         69        SEND_VAL_EX                                              ~42
         70        SEND_VAR_EX                                              !5
         71        DO_FCALL                                      0          
   31    72        INIT_FCALL_BY_NAME                                       'curl_setopt'
         73        SEND_VAR_EX                                              !8
         74        FETCH_CONSTANT                                   ~44     'CURLOPT_HTTPHEADER'
         75        SEND_VAL_EX                                              ~44
         76        SEND_VAR_EX                                              !7
         77        DO_FCALL                                      0          
   32    78        INIT_FCALL_BY_NAME                                       'curl_setopt'
         79        SEND_VAR_EX                                              !8
         80        FETCH_CONSTANT                                   ~46     'CURLOPT_SSL_VERIFYPEER'
         81        SEND_VAL_EX                                              ~46
         82        SEND_VAL_EX                                              <false>
         83        DO_FCALL                                      0          
   35    84        INIT_FCALL_BY_NAME                                       'curl_exec'
         85        SEND_VAR_EX                                              !8
         86        DO_FCALL                                      0  $48     
         87        ASSIGN                                                   !9, $48
   36    88        TYPE_CHECK                                    4          !9
         89      > JMPZ                                                     ~50, ->98
         90    >   NEW                                              $51     'Exception'
         91        INIT_FCALL_BY_NAME                                       'curl_error'
         92        SEND_VAR_EX                                              !8
         93        DO_FCALL                                      0  $52     
         94        CONCAT                                           ~53     'Could+not+get+reply%3A+', $52
         95        SEND_VAL_EX                                              ~53
         96        DO_FCALL                                      0          
         97      > THROW                                         0          $51
   37    98    >   INIT_FCALL                                               'json_decode'
         99        SEND_VAR                                                 !9
        100        SEND_VAL                                                 <true>
        101        DO_ICALL                                         $55     
        102        ASSIGN                                                   !10, $55
   38   103        BOOL_NOT                                         ~57     !10
        104      > JMPZ                                                     ~57, ->109
        105    >   NEW                                              $58     'Exception'
        106        SEND_VAL_EX                                              'Invalid+data+received%2C+please+make+sure+connection+is+working+and+requested+API+exists'
        107        DO_FCALL                                      0          
        108      > THROW                                         0          $58
   39   109    > > RETURN                                                   !10
   40   110*     > RETURN                                                   null

End of function btce_query

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.38 ms | 1407 KiB | 30 Q