Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1.     private function send($header = NULL, $data = NULL, $method = NULL)
  2.     {
  3.         $urlRequest = $this->server;
  4.  
  5.         $ch = curl_init();
  6.         curl_setopt($ch, CURLOPT_URL, $urlRequest);
  7.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8.  
  9.         if (!is_null($header)) {
  10.             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  11.         }
  12.  
  13.         if (!is_null($method)) {
  14.             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
  15.         }
  16.  
  17.         if (is_array($data)) {
  18.             curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlRequest=" . $data);
  19.         }
  20.  
  21.         $output = curl_exec($ch);
  22.         curl_close($ch);
  23.  
  24.         $xml = new SimpleXMLElement(json_decode($output, true));
  25.  
  26.         return $xml;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement