PHRets searchquery什么都不返回

时间:2014-06-08 18:53:57

标签: php rets phrets mls

我正在使用PHRets来获取mls数据。但它什么都没有。我从MLXchange网站获取数据。我使用了Retsconnector(桌面应用程序)及其获取数据。我在PHRets中使用了相同的查询,但它无法正常工作。

以下是我的代码。请帮帮我。

            <?
            $rets_modtimestamp_field = "80";


            $property_classes = array("4");


            $previous_start_time = "1980-01-01T00:00:00";

            //////////////////////////////

            require_once("phrets.php");

            // start rets connection
            $rets = new phRETS;

            $rets->AddHeader("User-Agent", "RETS-Connector/1.2");

            // only enable this if you know the server supports the optional RETS feature called 'Offset'
            $rets->SetParam("offset_support", true);

            echo "+ Connecting to {$rets_login_url} as {$rets_username}<br>\n";
            $connect = $rets->Connect($rets_login_url, $rets_username, $rets_password,$user_agent_password);

            if ($connect) {
                    echo "  + Connected<br>\n";
            }
            else {
                    echo "  + Not connected:<br>\n";
                    print_r($rets->Error());
                    exit;
            }

            foreach ($property_classes as $class) {

                    echo "+ Property:{$class}<br>\n";

                    $file_name = strtolower("property_{$class}.csv");
                    $fh = fopen($file_name, "w+");

                    $fields_order = array();

                    $query = "({$rets_modtimestamp_field}={$previous_start_time}+)";

                    // run RETS search
                    echo "   + Resource: Property   Class: {$class}   Query: {$query}<br>\n";
                    $search = $rets->SearchQuery("Property", $class, $query, array('Limit' => 1000));

                    if ($rets->NumRows($search) > 0) {

                            // print filename headers as first line
                            $fields_order = $rets->SearchGetFields($search);
                            fputcsv($fh, $fields_order);

                            // process results
                            while ($record = $rets->FetchRow($search)) {
                                    $this_record = array();
                                    foreach ($fields_order as $fo) {
                                            $this_record[] = $record[$fo];
                                    }
                                    fputcsv($fh, $this_record);
                            }

                    }

                    echo "    + Total found: {$rets->TotalRecordsFound($search)}<br>\n";

                    $rets->FreeResult($search);

                    fclose($fh);

                    echo "  - done<br>\n";

            }

            echo "+ Disconnecting<br>\n";
            $rets->Disconnect();

1 个答案:

答案 0 :(得分:0)

对于这个特定问题,您使用class(第二个参数)作为“4”。可能这是错误的。

对所有像我这样的人来说,

由于同一查询在“MLXchange”网站上有结果,因此我们在此行中有以下内容:$search = $rets->SearchQuery("Property", $class, $query, array('Limit' => 1000));

  1. 资源(第一个参数)
  2. 的值
  3. Class(第二个参数)的值
  4. 这些参数的值也因各种MLS'

    而异