Ask Your Question
0

PHRets only getting NULL

asked 2020-01-26 13:48:53 -0500

Hello, I'm using PHrets and every query I do always returns NULL. Here is what I have:

date_default_timezone_set('America/Denver');

// pull in the packages managed by Composer require_once("vendor/autoload.php");

// setup your configuration $config = new \PHRETS\Configuration; //$config->setLoginUrl('http://gbhar-rets.paragonrels.com/rets/fnisrets.aspx/GBHAR/login?rets-version=rets/1.7.2') $config->setLoginUrl('http://gbhar-rets.paragonrels.com/rets/fnisrets.aspx/GBHAR/login'); $config->setUsername('ailchuk'); $config->setPassword('**'); $config->setRetsVersion('1.7.2');

// get a session ready using the configuration $rets = new \PHRETS\Session($config);

// make the first request $connect = $rets->Login(); //var_dump($connect->getBody());

$query = "(ListingID=0+)"; $results = $rets->Search( 'Property', 'RE_1', $query, [ 'QueryType' => 'DMQL2', 'Count' => 1, 'Format' => 'COMPACT', 'Limit' => 5, 'StandardNames' => 1, 'Select' => 'ListingID,ListPrice', ]);

foreach ($results as $record) { var_dump($r); }

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-01-27 11:48:32 -0500

Using this script and your information I was able to download without issue:

date_default_timezone_set('America/Denver');
ini_set('memory_limit','16384M');
ini_set("default_socket_timeout", 6000); // seconds

require_once("vendor/autoload.php");

error_reporting(E_ALL & ~E_NOTICE);

$config = new \PHRETS\Configuration;

$config->setLoginUrl('http://gbhar-rets.paragonrels.com/rets/fnisrets.aspx/GBHAR/login')
->setUsername('ailchuk')
->setPassword('**')
->setRetsVersion('1.7.2');

//$config->setHttpAuthenticationMethod('digest'); // HTTP use 'digest'
//$config->setHttpAuthenticationMethod('basic'); // HTTPS use 'basic'

//var_dump($config);


$rets = new \PHRETS\Session($config);
//var_dump($rets);

try {
$connect = $rets->Login();
//var_dump($connect);
} catch (Exception $e)
{
echo "Login failed\n";
echo "Error: " . $e->getMessage() . "\n";
return;
}

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

$query = "(ListingID=0+)";
$select = 'ListingID,ListPrice';

try {

echo "\n";
$results = $rets->Search('Property', 'RE_1', $query, ['Limit' => 1, 'Count' => 2]);
$recordCount = $results->getTotalResultsCount();
echo "Record Count: {$recordCount}\n\n";

$results = $rets->Search('Property', 'RE_1', $query,
[
'QueryType' => 'DMQL2',
'Count' => 1,
'Format' => 'COMPACT',
'Limit' => 5,
'StandardNames' => 1,
'Select' => $select,
]);

echo "Search Results:" . "\n";
foreach ($results as $r) {
var_dump($r);
}

} catch (Exception $e)
{
echo "Search failed \n";
echo "Error: " . $e->getMessage() ."\n";
}

try {
$rets->Disconnect();
echo "\n";
echo "Logout" . "\n";
} catch (Exception $e)
{
echo "Logout failed\n";
echo "Error: " . $e->getMessage() . "\n";
}

edit flag offensive delete link more

Comments

That did it for me too. Thank you very much.

ailchuk gravatar imageailchuk ( 2020-01-27 11:56:51 -0500 )edit

You may want to use System Names instead of Standard Names if you want to get more data.
Our Standard Name use is pretty limited at this time.

bwolven gravatar imagebwolven ( 2020-01-27 11:59:45 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-01-26 13:48:53 -0500

Seen: 43 times

Last updated: Jan 27