static function requestWebservice($obj, $data, $bodyOnly = true)
 {
     if (!$obj) {
         return false;
     }
     //pr($data);
     $data = Request::toXml($data, $obj);
     pr($obj);
     pr($data);
     echo $data;
     die;
     //setting the curl parameters.
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, Request::IP_ADDRESS . $obj[Request::URL]);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
     curl_setopt($ch, CURLOPT_POSTFIELDS, "{$data}");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
     $data = curl_exec($ch);
     curl_close($ch);
     //convert the XML result into array
     $array_data = Request::toJson($data, $bodyOnly);
     print_r($array_data);
     return true;
 }
Example #2
0
 protected function processSingleObjectRequest(Request $request)
 {
     $postData = $request->toJson();
     /** @var \stdClass $response */
     $response = $this->post($postData);
     if ($this->responseHasErrors($response)) {
         throw new RandomOrgException($response->error->message);
     }
     return $response->result->random->data[0];
 }
Example #3
0
 public static function run($url, $xml, $json = 1)
 {
     //        $url = 'http://123.231.241.42:8280/'.$url;
     //$url = 'http://123.231.241.42:8281/PROD/'.$url;
     // IP lokal production
     //$url = 'http://192.168.0.35:8280/PROD/'.$url;
     // IP international production
     //        $url = 'http://123.231.241.42:8281/PROD/'.$url;
     //$url = 'https://tbs.webservices.visibleresults.net/LLWebService/'.$url;
     $url = Efiwebsetting::getData('LL_URL') . $url;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "{$xml}");
     $result = curl_exec($ch);
     // Check for errors and display the error message
     if ($errno = curl_errno($ch)) {
         $error_message = curl_strerror($errno);
         //            echo "cURL error ({$errno}):\n {$error_message}";
         $json['status_code'] = 0;
         $json['status_message'] = Efiwebsetting::getData('Constant_ll_failed');
         echo json_encode($json);
         die;
     }
     curl_close($ch);
     if ($json == 1) {
         return Request::toJson($result, 0);
     } elseif ($json == 2) {
         return simplexml_load_string($result);
     } elseif ($json == 3) {
         $xmlDoc = new DOMDocument();
         $xmlDoc->load($result);
         return $xmlDoc;
     } else {
         return $result;
     }
 }