Hi I'm creating a PHP fucntion to connect to pingomatic using CURL but the response is always.
Array ( [EXE] => XML-RPC server accepts POST requests only. )
here is my sample code...
function curl_getpage2($url,$data, $referer = null, $agent = null, $header = null, $timeout = 20, $proxy = null, $proxy_username = null, $proxy_password = null) {
//getProxy();
if ($agent == null) {
$agent = getAgent();
}
if ($referer == null) {
$referer = getHost($url);
}
if (!is_array($header)) {
$header = array("Content-Type:text/xml","Host:".getHost($url),"User-Agent:$agent",
"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language:en-us,en;q=0.5",
"Accept-Encoding:gzip,deflate",
"Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive:300",
"Connection:keep-alive",
"Cache-Control:max-age=0",
"Content-length: ".strlen($XML));
}
if($proxy == null){
$proxy = "208.100.27.155:60099";
}
if($proxy_username == null && $proxy_password == null){
$proxyUnPW = "unproxy:pwproxy";
}else{
$proxyUnPW = $proxy_username.":".$proxy_password;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD,$proxyUnPW);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
//curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//curl_setopt($ch, CURLOPT_REFERER, $referer);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt($ch, CURLOPT_AUTOREFERER,TRUE);
//curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
//curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
//curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result['EXE'] = curl_exec($ch);
//$result['INF'] = curl_getinfo($ch);
//$result['ERR'] = curl_error($ch);
curl_close($ch);
return $result;
}
I need some help here. i'm just somewhat new to php.
Thank you.