3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SmsGateway { static $baseUrl = "https://smsgateway.me"; function __construct($email,$password) { $this->email = $email; $this->password = $password; } function createContact ($name,$number) { return $this->makeRequest('/api/v3/contacts/create','POST',['name' => $name, 'number' => $number]); } function getContacts ($page=1) { return $this->makeRequest('/api/v3/contacts','GET',['page' => $page]); } function getContact ($id) { return $this->makeRequest('/api/v3/contacts/view/'.$id,'GET'); } function getDevices ($page=1) { return $this->makeRequest('/api/v3/devices','GET',['page' => $page]); } function getDevice ($id) { return $this->makeRequest('/api/v3/devices/view/'.$id,'GET'); } function getMessages($page=1) { return $this->makeRequest('/api/v3/messages','GET',['page' => $page]); } function getMessage($id) { return $this->makeRequest('/api/v3/messages/view/'.$id,'GET'); } function sendMessageToNumber($to, $message, $device, $options=[]) { $query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options); return $this->makeRequest('/api/v3/messages/send','POST',$query); } function sendMessageToManyNumbers ($to, $message, $device, $options=[]) { $query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options); return $this->makeRequest('/api/v3/messages/send','POST', $query); } function sendMessageToContact ($to, $message, $device, $options=[]) { $query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options); return $this->makeRequest('/api/v3/messages/send','POST', $query); } function sendMessageToManyContacts ($to, $message, $device, $options=[]) { $query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options); return $this->makeRequest('/api/v3/messages/send','POST', $query); } function sendManyMessages ($data) { $query['data'] = $data; return $this->makeRequest('/api/v3/messages/send','POST', $query); } private function makeRequest ($url, $method, $fields=[]) { $fields['email'] = $this->email; $fields['password'] = $this->password; $url = smsGateway::$baseUrl.$url; $fieldsString = http_build_query($fields); $ch = curl_init(); if($method == 'POST') { curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString); } else { $url .= '?'.$fieldsString; } curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $info = curl_getinfo($ch); $result = curl_exec ($ch); print_r($info['request_header']); $return['response'] = json_decode($result,true); if($return['response'] == false) $return['response'] = $result; $return['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close ($ch); return $return; } } $smsGateway = new SmsGateway('guritsanu.andrei@gmail.com', 'SMSGatewayVoldam'); $deviceID = 27389; $number = '0037379850506'; $message = 'Hello World!'; //Please note options is no required and can be left out $result = $smsGateway->sendMessageToNumber($number, $message, $deviceID); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  (null)
number of ops:  15
compiled vars:  !0 = $smsGateway, !1 = $deviceID, !2 = $number, !3 = $message, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   NEW                                              $5      'SmsGateway'
          1        SEND_VAL_EX                                              'guritsanu.andrei%40gmail.com'
          2        SEND_VAL_EX                                              'SMSGatewayVoldam'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $5
   85     5        ASSIGN                                                   !1, 27389
   86     6        ASSIGN                                                   !2, '0037379850506'
   87     7        ASSIGN                                                   !3, 'Hello+World%21'
   89     8        INIT_METHOD_CALL                                         !0, 'sendMessageToNumber'
          9        SEND_VAR_EX                                              !2
         10        SEND_VAR_EX                                              !3
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !4, $11
   90    14      > RETURN                                                   1

Class SmsGateway:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  __construct
number of ops:  7
compiled vars:  !0 = $email, !1 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN_OBJ                                               'email'
          3        OP_DATA                                                  !0
    6     4        ASSIGN_OBJ                                               'password'
          5        OP_DATA                                                  !1
    7     6      > RETURN                                                   null

End of function __construct

Function createcontact:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  createContact
number of ops:  11
compiled vars:  !0 = $name, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_METHOD_CALL                                         'makeRequest'
          3        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fcontacts%2Fcreate'
          4        SEND_VAL_EX                                              'POST'
          5        INIT_ARRAY                                       ~2      !0, 'name'
          6        ADD_ARRAY_ELEMENT                                ~2      !1, 'number'
          7        SEND_VAL_EX                                              ~2
          8        DO_FCALL                                      0  $3      
          9      > RETURN                                                   $3
   10    10*     > RETURN                                                   null

End of function createcontact

Function getcontacts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getContacts
number of ops:  9
compiled vars:  !0 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      1
   12     1        INIT_METHOD_CALL                                         'makeRequest'
          2        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fcontacts'
          3        SEND_VAL_EX                                              'GET'
          4        INIT_ARRAY                                       ~1      !0, 'page'
          5        SEND_VAL_EX                                              ~1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   13     8*     > RETURN                                                   null

End of function getcontacts

Function getcontact:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getContact
number of ops:  8
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_METHOD_CALL                                         'makeRequest'
          2        CONCAT                                           ~1      '%2Fapi%2Fv3%2Fcontacts%2Fview%2F', !0
          3        SEND_VAL_EX                                              ~1
          4        SEND_VAL_EX                                              'GET'
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   16     7*     > RETURN                                                   null

End of function getcontact

Function getdevices:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getDevices
number of ops:  9
compiled vars:  !0 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                        !0      1
   19     1        INIT_METHOD_CALL                                         'makeRequest'
          2        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fdevices'
          3        SEND_VAL_EX                                              'GET'
          4        INIT_ARRAY                                       ~1      !0, 'page'
          5        SEND_VAL_EX                                              ~1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   20     8*     > RETURN                                                   null

End of function getdevices

Function getdevice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getDevice
number of ops:  8
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        INIT_METHOD_CALL                                         'makeRequest'
          2        CONCAT                                           ~1      '%2Fapi%2Fv3%2Fdevices%2Fview%2F', !0
          3        SEND_VAL_EX                                              ~1
          4        SEND_VAL_EX                                              'GET'
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   24     7*     > RETURN                                                   null

End of function getdevice

Function getmessages:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getMessages
number of ops:  9
compiled vars:  !0 = $page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV_INIT                                        !0      1
   27     1        INIT_METHOD_CALL                                         'makeRequest'
          2        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages'
          3        SEND_VAL_EX                                              'GET'
          4        INIT_ARRAY                                       ~1      !0, 'page'
          5        SEND_VAL_EX                                              ~1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   28     8*     > RETURN                                                   null

End of function getmessages

Function getmessage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  getMessage
number of ops:  8
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_METHOD_CALL                                         'makeRequest'
          2        CONCAT                                           ~1      '%2Fapi%2Fv3%2Fmessages%2Fview%2F', !0
          3        SEND_VAL_EX                                              ~1
          4        SEND_VAL_EX                                              'GET'
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   32     7*     > RETURN                                                   null

End of function getmessage

Function sendmessagetonumber:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  sendMessageToNumber
number of ops:  19
compiled vars:  !0 = $to, !1 = $message, !2 = $device, !3 = $options, !4 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
   34     4        INIT_FCALL                                               'array_merge'
          5        INIT_ARRAY                                       ~5      !0, 'number'
          6        ADD_ARRAY_ELEMENT                                ~5      !1, 'message'
          7        ADD_ARRAY_ELEMENT                                ~5      !2, 'device'
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !4, $6
   35    12        INIT_METHOD_CALL                                         'makeRequest'
         13        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages%2Fsend'
         14        SEND_VAL_EX                                              'POST'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $8      
         17      > RETURN                                                   $8
   36    18*     > RETURN                                                   null

End of function sendmessagetonumber

Function sendmessagetomanynumbers:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  sendMessageToManyNumbers
number of ops:  19
compiled vars:  !0 = $to, !1 = $message, !2 = $device, !3 = $options, !4 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
   38     4        INIT_FCALL                                               'array_merge'
          5        INIT_ARRAY                                       ~5      !0, 'number'
          6        ADD_ARRAY_ELEMENT                                ~5      !1, 'message'
          7        ADD_ARRAY_ELEMENT                                ~5      !2, 'device'
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !4, $6
   39    12        INIT_METHOD_CALL                                         'makeRequest'
         13        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages%2Fsend'
         14        SEND_VAL_EX                                              'POST'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $8      
         17      > RETURN                                                   $8
   40    18*     > RETURN                                                   null

End of function sendmessagetomanynumbers

Function sendmessagetocontact:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  sendMessageToContact
number of ops:  19
compiled vars:  !0 = $to, !1 = $message, !2 = $device, !3 = $options, !4 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
   42     4        INIT_FCALL                                               'array_merge'
          5        INIT_ARRAY                                       ~5      !0, 'contact'
          6        ADD_ARRAY_ELEMENT                                ~5      !1, 'message'
          7        ADD_ARRAY_ELEMENT                                ~5      !2, 'device'
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !4, $6
   43    12        INIT_METHOD_CALL                                         'makeRequest'
         13        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages%2Fsend'
         14        SEND_VAL_EX                                              'POST'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $8      
         17      > RETURN                                                   $8
   44    18*     > RETURN                                                   null

End of function sendmessagetocontact

Function sendmessagetomanycontacts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  sendMessageToManyContacts
number of ops:  19
compiled vars:  !0 = $to, !1 = $message, !2 = $device, !3 = $options, !4 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
   46     4        INIT_FCALL                                               'array_merge'
          5        INIT_ARRAY                                       ~5      !0, 'contact'
          6        ADD_ARRAY_ELEMENT                                ~5      !1, 'message'
          7        ADD_ARRAY_ELEMENT                                ~5      !2, 'device'
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !4, $6
   47    12        INIT_METHOD_CALL                                         'makeRequest'
         13        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages%2Fsend'
         14        SEND_VAL_EX                                              'POST'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $8      
         17      > RETURN                                                   $8
   48    18*     > RETURN                                                   null

End of function sendmessagetomanycontacts

Function sendmanymessages:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smio2
function name:  sendManyMessages
number of ops:  10
compiled vars:  !0 = $data, !1 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   50     1        ASSIGN_DIM                                               !1, 'data'
          2        OP_DATA                                                  !0
   51     3        INIT_METHOD_CALL                                         'makeRequest'
          4        SEND_VAL_EX                                              '%2Fapi%2Fv3%2Fmessages%2Fsend'
          5        SEND_VAL_EX                                              'POST'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   52     9*     > RETURN                                                   null

End of function sendmanymessages

Function makerequest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 35
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
Branch analysis from position: 72
filename:       /in/smio2
function name:  makeRequest
number of ops:  84
compiled vars:  !0 = $url, !1 = $method, !2 = $fields, !3 = $fieldsString, !4 = $ch, !5 = $info, !6 = $result, !7 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   54     3        FETCH_OBJ_R                                      ~9      'email'
          4        ASSIGN_DIM                                               !2, 'email'
          5        OP_DATA                                                  ~9
   55     6        FETCH_OBJ_R                                      ~11     'password'
          7        ASSIGN_DIM                                               !2, 'password'
          8        OP_DATA                                                  ~11
   56     9        FETCH_STATIC_PROP_R          unknown             ~12     'baseUrl'
         10        CONCAT                                           ~13     ~12, !0
         11        ASSIGN                                                   !0, ~13
   57    12        INIT_FCALL                                               'http_build_query'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $15     
         15        ASSIGN                                                   !3, $15
   58    16        INIT_FCALL_BY_NAME                                       'curl_init'
         17        DO_FCALL                                      0  $17     
         18        ASSIGN                                                   !4, $17
   59    19        IS_EQUAL                                                 !1, 'POST'
         20      > JMPZ                                                     ~19, ->35
   61    21    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         22        SEND_VAR_EX                                              !4
         23        FETCH_CONSTANT                                   ~20     'CURLOPT_POST'
         24        SEND_VAL_EX                                              ~20
         25        COUNT                                            ~21     !2
         26        SEND_VAL_EX                                              ~21
         27        DO_FCALL                                      0          
   62    28        INIT_FCALL_BY_NAME                                       'curl_setopt'
         29        SEND_VAR_EX                                              !4
         30        FETCH_CONSTANT                                   ~23     'CURLOPT_POSTFIELDS'
         31        SEND_VAL_EX                                              ~23
         32        SEND_VAR_EX                                              !3
         33        DO_FCALL                                      0          
         34      > JMP                                                      ->37
   66    35    >   CONCAT                                           ~25     '%3F', !3
         36        ASSIGN_OP                                     8          !0, ~25
   68    37    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         38        SEND_VAR_EX                                              !4
         39        FETCH_CONSTANT                                   ~27     'CURLOPT_URL'
         40        SEND_VAL_EX                                              ~27
         41        SEND_VAR_EX                                              !0
         42        DO_FCALL                                      0          
   69    43        INIT_FCALL_BY_NAME                                       'curl_setopt'
         44        SEND_VAR_EX                                              !4
         45        FETCH_CONSTANT                                   ~29     'CURLOPT_SSL_VERIFYPEER'
         46        SEND_VAL_EX                                              ~29
         47        SEND_VAL_EX                                              <false>
         48        DO_FCALL                                      0          
   71    49        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         50        SEND_VAR_EX                                              !4
         51        DO_FCALL                                      0  $31     
         52        ASSIGN                                                   !5, $31
   72    53        INIT_FCALL_BY_NAME                                       'curl_exec'
         54        SEND_VAR_EX                                              !4
         55        DO_FCALL                                      0  $33     
         56        ASSIGN                                                   !6, $33
   74    57        INIT_FCALL                                               'print_r'
         58        FETCH_DIM_R                                      ~35     !5, 'request_header'
         59        SEND_VAL                                                 ~35
         60        DO_ICALL                                                 
   76    61        INIT_FCALL                                               'json_decode'
         62        SEND_VAR                                                 !6
         63        SEND_VAL                                                 <true>
         64        DO_ICALL                                         $38     
         65        ASSIGN_DIM                                               !7, 'response'
         66        OP_DATA                                                  $38
   77    67        FETCH_DIM_R                                      ~39     !7, 'response'
         68        BOOL_NOT                                         ~40     ~39
         69      > JMPZ                                                     ~40, ->72
   78    70    >   ASSIGN_DIM                                               !7, 'response'
         71        OP_DATA                                                  !6
   79    72    >   INIT_FCALL_BY_NAME                                       'curl_getinfo'
         73        SEND_VAR_EX                                              !4
         74        FETCH_CONSTANT                                   ~43     'CURLINFO_HTTP_CODE'
         75        SEND_VAL_EX                                              ~43
         76        DO_FCALL                                      0  $44     
         77        ASSIGN_DIM                                               !7, 'status'
         78        OP_DATA                                                  $44
   80    79        INIT_FCALL_BY_NAME                                       'curl_close'
         80        SEND_VAR_EX                                              !4
         81        DO_FCALL                                      0          
   81    82      > RETURN                                                   !7
   82    83*     > RETURN                                                   null

End of function makerequest

End of class SmsGateway.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.65 ms | 1420 KiB | 21 Q