Sending XML data using HTTP POST with PHP Sending XML data using HTTP POST with PHP codeigniter codeigniter

Sending XML data using HTTP POST with PHP


you can use cURL library for posting data:http://www.php.net/curl

$ch = curl_init();curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt($ch, CURLOPT_URL, "http://websiteURL");curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=".$xmlcontent."&password=".$password."&etc=etc");$content=curl_exec($ch);

where postfield contains XML you need to send - you will need to name the postfield the API service (Clickatell I guess) expects


Another option would be file_get_contents():

// $xml_str = your xml// $url = target url$post_data = array('xml' => $xml_str);$stream_options = array(    'http' => array(        'method'  => 'POST',        'header'  => 'Content-type: application/x-www-form-urlencoded' . "\r\n",        'content' =>  http_build_query($post_data)));$context  = stream_context_create($stream_options);$response = file_get_contents($url, null, $context);