3v4l.org

run code in 300+ PHP versions simultaneously
<?php class OpenCalaisHandler { private $apiKey; private $apiUrl = 'http://api.opencalais.com/enlighten/rest/'; private $contentType = 'TEXT/RAW'; private $outputFormat = 'Application/JSON'; private $relTag = 'http://www.stefan-nieuwenhuis.nl'; private $calcRel = true; //calculate relevance score? private $enableMeta = false; //GenericRelations,SocialTags private $rdfAccess = false; //save doc in Calais repository? private $allowDist = false; //can data be distributed? private $allowSearch = false; //allow data to be searched? private $extId = 'Stefan_Nieuwenhuis'; private $submitter = 'Stefan Nieuwenhuis'; private $inputString = ''; function __construct($apiKey) { $this->apiKey = $apiKey; $this->SetupConnection; } private function GetInput() { return $this->inputString; } private function SetupConnection() { $postFields = 'licenseID='.urlencode($this->apiKey); $postFields .= '&paramsXML='.urlencode($this->CreateParamXml()); $postFields .= '&content='.urlencode($this->GetInput()); $cf = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); curl_setopt($ch, CURLOPT_POST, 1); $response = curl_exec($cf); return $response; } private function CreateParamXml() { $xml = <<<XML <c:params xmlns:c="http://s.opencalais.com/1/pred/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <c:processingDirectives c:contentType="$this->contentType" c:enableMetadataType="$this->enableMeta" c:outputFormat="$this->outputFormat" c:docRDFaccesible="$this->rdfAccess" > </c:processingDirectives> <c:userDirectives c:allowDistribution="$this->allowDist" c:allowSearch="$this->allowSearch" c:externalID="$this->extId" c:submitter="$this->submitter"> </c:userDirectives> <c:externalMetadata> </c:externalMetadata> </c:params> XML; return $xml; } } $class = new OpenCalaisHandler('kx78mmny8st4qa8q5ry5uvv9'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFnLa
function name:  (null)
number of ops:  5
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   NEW                                              $1      'OpenCalaisHandler'
          1        SEND_VAL_EX                                              'kx78mmny8st4qa8q5ry5uvv9'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   66     4      > RETURN                                                   1

Class OpenCalaisHandler:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFnLa
function name:  __construct
number of ops:  6
compiled vars:  !0 = $apiKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               'apiKey'
          2        OP_DATA                                                  !0
   23     3        FETCH_OBJ_R                                      ~2      'SetupConnection'
          4        FREE                                                     ~2
   24     5      > RETURN                                                   null

End of function __construct

Function getinput:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFnLa
function name:  GetInput
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'inputString'
          1      > RETURN                                                   ~0
   29     2*     > RETURN                                                   null

End of function getinput

Function setupconnection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFnLa
function name:  SetupConnection
number of ops:  61
compiled vars:  !0 = $postFields, !1 = $cf, !2 = $ch, !3 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'urlencode'
          1        FETCH_OBJ_R                                      ~4      'apiKey'
          2        SEND_VAL                                                 ~4
          3        DO_ICALL                                         $5      
          4        CONCAT                                           ~6      'licenseID%3D', $5
          5        ASSIGN                                                   !0, ~6
   34     6        INIT_FCALL                                               'urlencode'
          7        INIT_METHOD_CALL                                         'CreateParamXml'
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                         $9      
         11        CONCAT                                           ~10     '%26paramsXML%3D', $9
         12        ASSIGN_OP                                     8          !0, ~10
   35    13        INIT_FCALL                                               'urlencode'
         14        INIT_METHOD_CALL                                         'GetInput'
         15        DO_FCALL                                      0  $12     
         16        SEND_VAR                                                 $12
         17        DO_ICALL                                         $13     
         18        CONCAT                                           ~14     '%26content%3D', $13
         19        ASSIGN_OP                                     8          !0, ~14
   37    20        INIT_FCALL_BY_NAME                                       'curl_init'
         21        DO_FCALL                                      0  $16     
         22        ASSIGN                                                   !1, $16
   38    23        INIT_FCALL_BY_NAME                                       'curl_setopt'
         24        SEND_VAR_EX                                              !2
         25        FETCH_CONSTANT                                   ~18     'CURLOPT_URL'
         26        SEND_VAL_EX                                              ~18
         27        CHECK_FUNC_ARG                                           
         28        FETCH_OBJ_FUNC_ARG                               $19     'apiUrl'
         29        SEND_FUNC_ARG                                            $19
         30        DO_FCALL                                      0          
   39    31        INIT_FCALL_BY_NAME                                       'curl_setopt'
         32        SEND_VAR_EX                                              !2
         33        FETCH_CONSTANT                                   ~21     'CURLOPT_RETURNTRANSFER'
         34        SEND_VAL_EX                                              ~21
         35        SEND_VAL_EX                                              1
         36        DO_FCALL                                      0          
   40    37        INIT_FCALL_BY_NAME                                       'curl_setopt'
         38        SEND_VAR_EX                                              !2
         39        FETCH_CONSTANT                                   ~23     'CURLOPT_HEADER'
         40        SEND_VAL_EX                                              ~23
         41        SEND_VAL_EX                                              0
         42        DO_FCALL                                      0          
   41    43        INIT_FCALL_BY_NAME                                       'curl_setopt'
         44        SEND_VAR_EX                                              !2
         45        FETCH_CONSTANT                                   ~25     'CURLOPT_POSTFIELDS'
         46        SEND_VAL_EX                                              ~25
         47        SEND_VAR_EX                                              !0
         48        DO_FCALL                                      0          
   42    49        INIT_FCALL_BY_NAME                                       'curl_setopt'
         50        SEND_VAR_EX                                              !2
         51        FETCH_CONSTANT                                   ~27     'CURLOPT_POST'
         52        SEND_VAL_EX                                              ~27
         53        SEND_VAL_EX                                              1
         54        DO_FCALL                                      0          
   44    55        INIT_FCALL_BY_NAME                                       'curl_exec'
         56        SEND_VAR_EX                                              !1
         57        DO_FCALL                                      0  $29     
         58        ASSIGN                                                   !3, $29
   45    59      > RETURN                                                   !3
   46    60*     > RETURN                                                   null

End of function setupconnection

Function createparamxml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFnLa
function name:  CreateParamXml
number of ops:  28
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   ROPE_INIT                                    17  ~10     '%09%3Cc%3Aparams+xmlns%3Ac%3D%22http%3A%2F%2Fs.opencalais.com%2F1%2Fpred%2F%22+xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%3E%0A%09%3Cc%3AprocessingDirectives+c%3AcontentType%3D%22'
   52     1        FETCH_OBJ_R                                      ~1      'contentType'
          2        ROPE_ADD                                      1  ~10     ~10, ~1
          3        ROPE_ADD                                      2  ~10     ~10, '%22+c%3AenableMetadataType%3D%22'
          4        FETCH_OBJ_R                                      ~2      'enableMeta'
          5        ROPE_ADD                                      3  ~10     ~10, ~2
          6        ROPE_ADD                                      4  ~10     ~10, '%22+c%3AoutputFormat%3D%22'
          7        FETCH_OBJ_R                                      ~3      'outputFormat'
          8        ROPE_ADD                                      5  ~10     ~10, ~3
          9        ROPE_ADD                                      6  ~10     ~10, '%22+c%3AdocRDFaccesible%3D%22'
         10        FETCH_OBJ_R                                      ~4      'rdfAccess'
         11        ROPE_ADD                                      7  ~10     ~10, ~4
         12        ROPE_ADD                                      8  ~10     ~10, '%22+%3E%0A%09%3C%2Fc%3AprocessingDirectives%3E%0A%09%3Cc%3AuserDirectives+c%3AallowDistribution%3D%22'
   54    13        FETCH_OBJ_R                                      ~5      'allowDist'
         14        ROPE_ADD                                      9  ~10     ~10, ~5
         15        ROPE_ADD                                     10  ~10     ~10, '%22+c%3AallowSearch%3D%22'
         16        FETCH_OBJ_R                                      ~6      'allowSearch'
         17        ROPE_ADD                                     11  ~10     ~10, ~6
         18        ROPE_ADD                                     12  ~10     ~10, '%22+c%3AexternalID%3D%22'
         19        FETCH_OBJ_R                                      ~7      'extId'
         20        ROPE_ADD                                     13  ~10     ~10, ~7
         21        ROPE_ADD                                     14  ~10     ~10, '%22+c%3Asubmitter%3D%22'
         22        FETCH_OBJ_R                                      ~8      'submitter'
         23        ROPE_ADD                                     15  ~10     ~10, ~8
         24        ROPE_END                                     16  ~9      ~10, '%22%3E%0A%09%3C%2Fc%3AuserDirectives%3E%0A%09%3Cc%3AexternalMetadata%3E%0A%09%3C%2Fc%3AexternalMetadata%3E%0A%09%3C%2Fc%3Aparams%3E'
   50    25        ASSIGN                                                   !0, ~9
   61    26      > RETURN                                                   !0
   62    27*     > RETURN                                                   null

End of function createparamxml

End of class OpenCalaisHandler.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.86 ms | 1404 KiB | 15 Q