Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. function fncPostXMLToURL($url, $page, $xml_data) {
  2.  
  3.         $headers = array(
  4.                 "POST ".$page." HTTP/1.0",
  5.                 "Content-type: text/xml;charset=\"utf-8\"",
  6.                 "Accept: text/xml",
  7.                 "Cache-Control: no-cache",
  8.                 "Pragma: no-cache",
  9.                 "Content-length: ".strlen($xml_data),
  10.         );
  11.  
  12.  
  13. $ch = curl_init();
  14.     curl_setopt($ch, CURLOPT_URL,$url);
  15.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16.     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  17.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  18.     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  19.  
  20.  
  21.         // Apply the XML to our curl call
  22.         curl_setopt($ch, CURLOPT_POST, 1);
  23.         curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
  24.  
  25.         $data = curl_exec($ch);
  26.  
  27.         if (curl_errno($ch)) {
  28.                 return "Error: " . curl_error($ch);
  29.         } else {
  30.                 return $data;
  31.                 curl_close($ch);
  32.         }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement