3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 = md5('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'); $extId = md5('Stefan Nieuwenhuis'); ?>
Output for 5.3.0 - 5.4.19
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/lVAYu on line 15
Process exited with code 255.