使用PHrets从RETS服务器获取空响应

时间:2015-12-05 10:18:28

标签: rets phrets

我连接到RETS服务器,我能够使用PHrets库中的函数获取所有元数据,如GetMetadataResources,GetMetadataClasses和每个类中的所有feild,但是我无法使用SearchQuery从该服务器获取数据,我试过各方面但没有运气。

<pre>
    /* Initialize Object */
 require("PHRets_CREA.php");
require("credentials.php");
$rets = new PHRets();
$connect=$rets->Connect($RETSURL, $RETSUsername, $RETSPassword);
    /* Connect */
    /* Query Server */
    if ($connect) {
        echo "Connected";
$resources = $rets->GetMetadataResources();
foreach ($resources as $resource) {
        echo "+ Resource {$resource['ResourceID']}\n";
        $classes = $rets->GetMetadataClasses($resource['ResourceID']);
        foreach ($classes as $class) {
                echo "   + Class {$class['ClassName']} described as " . $class['Description'] . "\n";
        $rets_metadata = $rets->GetMetadata($resource['ResourceID'],$class['ClassName']);
        foreach ($rets_metadata as $field) {
            echo "    + Field: {$field['SystemName']} ({$field['DataType']})\n";
        }
        }
}
/*
$search = $rets->SearchQuery("Property","RE_1","(L_ListingDate=2010-03-02-2010-03-03)");
while ($listing = $rets->FetchRow($search)) {
  echo $listing['L_ListingID'];
        }*/
$search = $rets->SearchQuery("Property","ResidentialProperty","(ListDate=1990-01-01+)",
array( "Count" => 1, "Format" => "COMPACT", "Limit" => "2", "Offset" => "2",
"RestrictedIndicator" => "****", "StandardNames" => 1 )
);
echo "data";
print_r($search);
while ($listing = $rets->FetchRow($search)) 
 echo "{$listing['L_City']}";exit; 
}
$rets->FreeResult($search);
}</pre>

Thanks

2 个答案:

答案 0 :(得分:0)

首先确保您的资源和类名称正确无误。使用http://retsmd.com进行验证。资源通常是“属性”,但请检查您目前拥有的“ResidentialProperty”的类名。您可能在上面的代码中使用了“RE_1”。

接下来,修改您的SearchQuery。也许在options数组中使用较少的参数,并尝试删除StandardNames并使用默认的系统名称。

这样的事情:

$search = $rets->SearchQuery("Property","RE_1","(L_ListingDate=1990-01-01+)", array("Limit" => "10"));

答案 1 :(得分:0)

请尝试这个,我们为此获得所有活动属性。

$ search = $ rets-&gt; SearchQuery(&#34; Property&#34;,&#34; 1&#34;,&#34;(135 = 1990-01-01 +),(246 = A )&#34);