2012年10月7日 星期日

PHP XML


function http_get($url,$header=array("Content-Type: text/xml;charset=utf-8")){
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
 $ret = curl_exec($ch);
 curl_close($ch);
 return $ret;
}

function http_post($url,$params,$xml_post = true){
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
 curl_setopt($ch, CURLOPT_POST, 1);
 if($xml_post) curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
 curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
 $ret = curl_exec($ch);
 curl_close($ch);
 return $ret;
}


出處
http://qxbbs.org/viewtopic.php?p=1039323&sid=d94ea6385045e4b3cc6b32c8a282299c

沒有留言:

張貼留言