Post URL and read xml response though PHP socket



need to post request in URL and read response in xml.i tried using curl but response time is large,so i want to try with socket,can anyone pls tell how to make the below possible using socket program



<?
$ch = curl_init();

//Define curl options in an array
$options = array(CURLOPT_URL => "http://ift.tt/1CFJsRm;",

CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 200, // timeout on response
CURLOPT_POST => 1, // sending post data
CURLOPT_POSTFIELDS => $curl_data, // post vars
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
CURLOPT_SSL_VERIFYPEER => false, //
CURLOPT_VERBOSE => 1, //
CURLOPT_HEADER => "Content-Type:application/xml", //
CURLOPT_HTTPAUTH => CURLAUTH_BASIC, //
);

//Set options against curl object
$curl_data = "var1=60&var2=test";
curl_setopt_array($ch, $options);


$start = array_sum(explode(' ', microtime()));
$data = curl_exec($ch);
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;

?>

No comments:

Post a Comment