Search code examples
retsphrets

PHP Fatal error:Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery


I am using the PHRETS PHP library to fetch the RETS data from the rets API. I have and issue with getting the Data. It's giving "PHP Fatal error: Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery. Reference ID: fc63ca3e-c8a8-44cf-a0ce-4c729ce91fcc' in /XXXX/vendor/troydavisson/phrets/src/Session.php:379". Please help to solve this Error. My Code is:

<pre><code>
date_default_timezone_set('America/New_York');
require_once("vendor/autoload.php");
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://sef.rets.interealty.com/Login.asmx/Login');
$config->setUsername('XXXX');
$config->setPassword('XXXX');
// optional.  value shown below are the defaults used when not overridden
$config->setRetsVersion('1.7.2'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('RETS-Connector/1.2');
$config->setUserAgentPassword('123456'); // string password, if given
$config->setOption('use_post_method', false); // boolean
$config->setOption('disable_follow_location', false); // boolean

$session = new \PHRETS\Session($config);

$connect = $session->Login();

$system = $session->GetSystemMetadata();
//var_dump($system);

$resources = $system->getResources();
$classes = $resources->first()->getClasses();
//var_dump($classes);

$classes = $session->GetClassesMetadata('Property');
//var_dump($classes->first());

$results = $session->Search("Property", "2", "*", ['Limit' => 3, 'Select' => '922']);
foreach ($results as $r) {
    var_dump($r);
}
</pre></code>

And It returning error : [11-Mar-2017 06:32:59 America/New_York] PHP Fatal error: Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Missing open parenthesis in subquery. Reference ID: fc63ca3e-c8a8-44cf-a0ce-4c729ce91fcc' in /home2/XXXX/vendor/troydavisson/phrets/src/Session.php:379 Stack trace:

0 /home2/XXXX/vendor/troydavisson/phrets/src/Session.php(297): PHRETS\Session->request('Search', Array)

1 /home2/XXXX/index.php(34): PHRETS\Session->Search('Property', '2', '*', Array)

2 {main}

thrown in /home2/XXXX/vendor/troydavisson/phrets/src/Session.php on line 379


Solution

  • Performing searches through RETS using an asterisk is something only a few servers support. In every other case, a normal query needs to be given which is surrounded with parentheses.

    You can see this tutorial for a brief introduction in the query structure used by RETS:

    https://www.flexmls.com/developers/rets/tutorials/dmql-tutorial/

    For that particular server, one example to get you going could be:

    (sysid=0+)