Friday

php function for dot.net webservice submission




<?
function web_service($serv,$plain_data){
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "https://myserver.com/myService.asmx/".$serv);
curl_setopt($curl_handle, CURLOPT_HEADER, 1);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $plain_data);
$response = curl_exec ($curl_handle) or die ( "There has been an error connecting");
#echo $response;
curl_close ($curl_handle);
$response= strstr($response, '<?xml version="1.0" encoding="utf-8"?>');
$re = str_replace('&gt;','>',str_replace('&lt;','<',$response));
$re1= str_replace('<string xmlns="http://tempuri.org/">',"<string>",$re);

return $re1;
}


function web_method($f,$u){

$data="Subscriber=".$f['studid']."&Affiliate=".$u['referral']
$re1= msi_service("MyMethodName1",$data);
$xml = simplexml_load_string($re1);
$result = $xml->xpath("/string"); // <- parsing result
foreach($result as $result_code) {
return $result_code;
}
return $re1;
}
?>



here is post how to configure web service to allow remote post/get submission

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...