| |
 |
//creating header for http post request
$myHeader = array(
"MIME-Version: 1.0",
"Content-type: text/xml; charset=utf-8"
);
//creating and initiating curl
$ch = curl_init();
//setting curl/http headers
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlstring);
curl_setopt($ch, CURLOPT_URL," http://xml.telemessage.com/partners/xmlMessage.jsp ");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $myHeader);
//executing http request and getting response. $postResult will contain response xml from TeleMessage.
$postResult = curl_exec($ch);
if (curl_errno($ch)) {
return null;
/*
* for PHP5 you can throw Exception:
* throw new Exception("Error while sending");
*/
}
curl_close($ch);
return $postResult;
|