我创建了以下 PHP 脚本来显示我们使用的 SOAP API 的属性列表。
当我们有多个要宣传的属性时,该脚本可以正常工作,但当我们只有一个要宣传的属性时,脚本不会显示任何内容。
谁能告诉我我做错了什么或简单的检查可以解决问题?
我的代码是:
$wsdl = "http://portal.letmc.com/PropertySearchService.asmx?WSDL";
$client = new SoapClient($wsdl, array ("trace"=>1, "exceptions"=>0));
$strClientID = "{xxxx-xxxx-xxxx-xxxx}";
$strBranchID = "{xxxx-xxxx-xxxx-xxxx}";
$nMaxResults = "5";
$nRentMinimum = 100;
$nRentMaximum = 900;
$nMaximumTenants = 5;
$parameters = array( "strClientID"=>$strClientID,
"strBranchID"=>$strBranchID,
"nMaxResults"=>$nMaxResults,
"nRentMinimum"=>$nRentMinimum,
"nRentMaximum"=>$nRentMaximum,
"nMaximumTenants"=>$nMaximumTenants
);
$values = $client->SearchProperties($parameters);
if($values != '')
{
echo "<table>";
echo '<tr>
<th>Apartment</th>
<th class="center">Bedrooms</th>
<th>Rent</th>
<th>Description</th>
</tr>';
foreach ($values->SearchPropertiesResult->PropertyInfo as $message)
{
$address = $message->Address1;
$rooms = $message->MaxTenants;
$rent = $message->Rent;
$description = $message->Description;
echo '<tr>';
echo '<td>'. $address .'</td>
<td class="center">'. $rooms .'</td>
<td>'. $rent .'</td>
<td>'. $description .'</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
echo '<p><strong>Sorry, we have no properties available.</strong></p> <p>Please register your details on the right and we will let you know as soon as an apartment comes available.</p>';
}