mrl22
5/26/2017 - 9:03 AM

Get LetMC Properties

Get LetMC Properties

$clientid = '{0000-0000-0000-0000}';


function letmc_call($action, $xml) {
	
	$headers = array(
		"Content-type: text/xml;charset=\"utf-8\"",
		"Accept: text/xml",
		"Cache-Control: no-cache",
		"Pragma: no-cache",
		"SOAPAction: http://portal.letmc.com/".$action, 
		"Content-length: ".strlen($xml),
	); 
	
	$ch = curl_init("http://portal.letmc.com/PropertySearchService.asmx");
	//curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
	//curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w'));
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
	curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$response = curl_exec($ch); 
	curl_close($ch);
	$response1 = str_replace("<soap:Body>","",$response);
	$response2 = str_replace("</soap:Body>","",$response1);
	return simplexml_load_string($response2);
	
}

$xml = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetBranches xmlns="http://portal.letmc.com">
      <strClientID>'.$clientid.'</strClientID>
    </GetBranches>
  </soap:Body>
</soap:Envelope>';

$branches = letmc_call('GetBranches', $xml);

$firstbranchid = $branches->GetBranchesResponse->GetBranchesResult->BranchInfo->{0}->ID;

$xml = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetPropertyDetails xmlns="http://portal.letmc.com">
      <strClientID>'.$clientid.'</strClientID>
      <objPropertyIDs>
        <string>'.$_GET['id'].'</string>
      </objPropertyIDs>
    </GetPropertyDetails>
  </soap:Body>
</soap:Envelope>'; 

$p = letmc_call('GetPropertyDetails', $xml);