Cannot Get GetObject to pull anything
I've scoured the other posts for help but what others say works will not for me. Please let me know what I am doing wrong.
<?php
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 = "(L_ListingId=0+)";
try {
echo "\n";
$results = $rets->Search('Property', 'RE_1', $query, ['Limit' => 1, 'Count' => 2]);
$recordCount = $results->getTotalResultsCount();
echo "Record Count: {$recordCount}\n\n";
echo "Search Results:" . "\n";
$objectIds = $listingID;
$objects = $rets->GetObject('Property', 'Photo', '10453', '*', 1);
$objectCount = 0;
$objectFailedCount = 0;
foreach ($objects as $object) {
// Does this represent some kind of error
if ($object->isError())
{
$objectFailedCount++;
$errorInfo = $object->getError();
//var_dump($errorInfo);
echo "\ncode: " . $errorInfo->getCode();
echo "\nmessage: " . $errorInfo->getMessage();
echo "\ngetContentId: " . $object->getContentId();
echo "\ngetObjectId: " . $object->getObjectId();
echo "\ngetContentType: " . $object->getContentType();
echo "\ngetContent: \n" . $object->getContent();
echo "\n\n";
continue;
}
$objectCount++;
// get the record ID associated with this object
echo "\ngetContentId: " . $object->getContentId();
// get the sequence number of this object relative to the others with the same ContentId
echo "\ngetObjectId: " . $object->getObjectId();
// get the description of the object
echo "\ngetContentDescription: " . $object->getContentDescription();
// get the sub-description of the object
echo "\ngetContentSubDescription: " . $object->getContentSubDescription();
// get the size of the object"s data
echo "\ngetSize: " . $object->getSize();
// does this object represent the primary object in the set
echo "\nisPreferred: " . $object->isPreferred();
// when requesting URLs, access the URL given back
echo "\ngetLocation: \n" . $object->getLocation();
// get the object"s Content-Type value
echo "\ngetContentType: " . $object->getContentType();
// get the object"s binary data
echo "\ngetContent: \n" . $object->getContent();
// use the given URL and make it look like the RETS server gave the object directly
// $object->setContent(file_get_contents('http:' . $object->getLocation()));
// echo "\nDownloaded-getSize: " . $object->getSize();
echo "\n\n";
}
echo "Object Count: $objectCount\n";
echo "Object Failed Count: $objectFailedCount\n";
echo "\n\n";
} catch (Exception $e)
{
echo "Search failed \n";
echo "Error: " . $e->getMessage() ."\n";
echo $query;
}
try {
$rets->Disconnect();
echo "\n";
echo "Logout" . "\n";
} catch (Exception $e)
{
echo "Logout failed\n";
echo "Error: " . $e->getMessage() . "\n";
}
?>
Comments