3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('APPKEY','XXXXXXXXXXXXXXX'); // Your app key define('PUSHSECRET', 'XXXXXXXXXXXXXXX'); // Your master Secret define('PUSHURL', 'https://go.urbanairship.com/api/push/'); $iosspecific = array(); $iosspecific['badge'] = "+1"; $iosspecific['sound'] = "cat.caf"; $notification = array(); $notification['alert'] = "PHP script test with rich push"; $notification['ios'] = $iosspecific; $platform = array(); array_push($platform, "ios"); array_push($platform, "android"); //comment out if you don't want Android $richpush = array(); $richpush['title'] = "Title of rich push"; $richpush['body'] = "Body of rich push"; $push = array("audience"=>"all", "notification"=>$notification, "device_types"=>$platform, "message"=>$richpush); $json = json_encode($push); echo $json; //show the payload $session = curl_init(PUSHURL); curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET); curl_setopt($session, CURLOPT_POST, True); curl_setopt($session, CURLOPT_POSTFIELDS, $json); curl_setopt($session, CURLOPT_HEADER, False); curl_setopt($session, CURLOPT_RETURNTRANSFER, True); curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Accept: application/vnd.urbanairship+json; version=3;')); $content = curl_exec($session); echo $content; //show the response text // Check if any error occured $response = curl_getinfo($session); if($response['http_code'] != 202) { echo "Got negative response from server, http code: ". $response['http_code'] . "\n"; } else { echo "Wow, it worked!\n"; } curl_close($session); ?><?php
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 103, Position 2 = 108
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 108
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DirYL
function name:  (null)
number of ops:  113
compiled vars:  !0 = $iosspecific, !1 = $notification, !2 = $platform, !3 = $richpush, !4 = $push, !5 = $json, !6 = $session, !7 = $content, !8 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'APPKEY'
          2        SEND_VAL                                                 'XXXXXXXXXXXXXXX'
          3        DO_ICALL                                                 
    3     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'PUSHSECRET'
          6        SEND_VAL                                                 'XXXXXXXXXXXXXXX'
          7        DO_ICALL                                                 
    4     8        INIT_FCALL                                               'define'
          9        SEND_VAL                                                 'PUSHURL'
         10        SEND_VAL                                                 'https%3A%2F%2Fgo.urbanairship.com%2Fapi%2Fpush%2F'
         11        DO_ICALL                                                 
    6    12        ASSIGN                                                   !0, <array>
    7    13        ASSIGN_DIM                                               !0, 'badge'
         14        OP_DATA                                                  '%2B1'
    8    15        ASSIGN_DIM                                               !0, 'sound'
         16        OP_DATA                                                  'cat.caf'
    9    17        ASSIGN                                                   !1, <array>
   10    18        ASSIGN_DIM                                               !1, 'alert'
         19        OP_DATA                                                  'PHP+script+test+with+rich+push'
   11    20        ASSIGN_DIM                                               !1, 'ios'
         21        OP_DATA                                                  !0
   12    22        ASSIGN                                                   !2, <array>
   13    23        INIT_FCALL                                               'array_push'
         24        SEND_REF                                                 !2
         25        SEND_VAL                                                 'ios'
         26        DO_ICALL                                                 
   14    27        INIT_FCALL                                               'array_push'
         28        SEND_REF                                                 !2
         29        SEND_VAL                                                 'android'
         30        DO_ICALL                                                 
   15    31        ASSIGN                                                   !3, <array>
   16    32        ASSIGN_DIM                                               !3, 'title'
         33        OP_DATA                                                  'Title+of+rich+push'
   17    34        ASSIGN_DIM                                               !3, 'body'
         35        OP_DATA                                                  'Body+of+rich+push'
   19    36        INIT_ARRAY                                       ~24     'all', 'audience'
         37        ADD_ARRAY_ELEMENT                                ~24     !1, 'notification'
         38        ADD_ARRAY_ELEMENT                                ~24     !2, 'device_types'
         39        ADD_ARRAY_ELEMENT                                ~24     !3, 'message'
         40        ASSIGN                                                   !4, ~24
   21    41        INIT_FCALL                                               'json_encode'
         42        SEND_VAR                                                 !4
         43        DO_ICALL                                         $26     
         44        ASSIGN                                                   !5, $26
   22    45        ECHO                                                     !5
   24    46        INIT_FCALL_BY_NAME                                       'curl_init'
         47        FETCH_CONSTANT                                   ~28     'PUSHURL'
         48        SEND_VAL_EX                                              ~28
         49        DO_FCALL                                      0  $29     
         50        ASSIGN                                                   !6, $29
   25    51        INIT_FCALL_BY_NAME                                       'curl_setopt'
         52        SEND_VAR_EX                                              !6
         53        FETCH_CONSTANT                                   ~31     'CURLOPT_USERPWD'
         54        SEND_VAL_EX                                              ~31
         55        FETCH_CONSTANT                                   ~32     'APPKEY'
         56        CONCAT                                           ~33     ~32, '%3A'
         57        FETCH_CONSTANT                                   ~34     'PUSHSECRET'
         58        CONCAT                                           ~35     ~33, ~34
         59        SEND_VAL_EX                                              ~35
         60        DO_FCALL                                      0          
   26    61        INIT_FCALL_BY_NAME                                       'curl_setopt'
         62        SEND_VAR_EX                                              !6
         63        FETCH_CONSTANT                                   ~37     'CURLOPT_POST'
         64        SEND_VAL_EX                                              ~37
         65        SEND_VAL_EX                                              <true>
         66        DO_FCALL                                      0          
   27    67        INIT_FCALL_BY_NAME                                       'curl_setopt'
         68        SEND_VAR_EX                                              !6
         69        FETCH_CONSTANT                                   ~39     'CURLOPT_POSTFIELDS'
         70        SEND_VAL_EX                                              ~39
         71        SEND_VAR_EX                                              !5
         72        DO_FCALL                                      0          
   28    73        INIT_FCALL_BY_NAME                                       'curl_setopt'
         74        SEND_VAR_EX                                              !6
         75        FETCH_CONSTANT                                   ~41     'CURLOPT_HEADER'
         76        SEND_VAL_EX                                              ~41
         77        SEND_VAL_EX                                              <false>
         78        DO_FCALL                                      0          
   29    79        INIT_FCALL_BY_NAME                                       'curl_setopt'
         80        SEND_VAR_EX                                              !6
         81        FETCH_CONSTANT                                   ~43     'CURLOPT_RETURNTRANSFER'
         82        SEND_VAL_EX                                              ~43
         83        SEND_VAL_EX                                              <true>
         84        DO_FCALL                                      0          
   30    85        INIT_FCALL_BY_NAME                                       'curl_setopt'
         86        SEND_VAR_EX                                              !6
         87        FETCH_CONSTANT                                   ~45     'CURLOPT_HTTPHEADER'
         88        SEND_VAL_EX                                              ~45
         89        SEND_VAL_EX                                              <array>
         90        DO_FCALL                                      0          
   31    91        INIT_FCALL_BY_NAME                                       'curl_exec'
         92        SEND_VAR_EX                                              !6
         93        DO_FCALL                                      0  $47     
         94        ASSIGN                                                   !7, $47
   32    95        ECHO                                                     !7
   35    96        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         97        SEND_VAR_EX                                              !6
         98        DO_FCALL                                      0  $49     
         99        ASSIGN                                                   !8, $49
   36   100        FETCH_DIM_R                                      ~51     !8, 'http_code'
        101        IS_NOT_EQUAL                                             ~51, 202
        102      > JMPZ                                                     ~52, ->108
   38   103    >   FETCH_DIM_R                                      ~53     !8, 'http_code'
        104        CONCAT                                           ~54     'Got+negative+response+from+server%2C+http+code%3A+', ~53
        105        CONCAT                                           ~55     ~54, '%0A'
        106        ECHO                                                     ~55
        107      > JMP                                                      ->109
   41   108    >   ECHO                                                     'Wow%2C+it+worked%21%0A'
   44   109    >   INIT_FCALL_BY_NAME                                       'curl_close'
        110        SEND_VAR_EX                                              !6
        111        DO_FCALL                                      0          
   45   112      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.05 ms | 1408 KiB | 19 Q