Ask Your Question
0

Please help me to get the data from RETS Server. I am trying to use Phrets library but their documentation is old and mostly functions are not working.

asked 2018-08-07 04:48:35 -0600

taminstudios gravatar image

updated 2018-08-07 05:24:14 -0600

URL: http://blackhills.rets.paragonrels.co... User: RETSWALT17

http://blackhills.rets.paragonrels.co...

I am getting error here This XML file does not appear to have any style information associated with it. The document tree is shown below. <rets replycode="20036" replytext="Miscellaneous server login error. Missing RETS-Version"> </rets>

http://blackhills.rets.paragonrels.co...)

I am getting error here also This XML file does not appear to have any style information associated with it. The document tree is shown below. <rets replycode="20036" replytext="Miscellaneous server login error. Missing RETS-Version"> </rets>

while I am able to get some information here only.. http://blackhills.rets.paragonrels.co...

Please help me to get the data from RETS Server. I am trying to use Phrets library but their documentation is old and mostly functions are not working.

edit retag flag offensive close merge delete

Comments

When using the URLs in a browser, you need to have the rets-version parameter in each request.
What kind of issues are you having with PHRETS?
I'm not a PHP developer, but I was able to get basic functionality just using the command line.
Was able to do: login, disconnect (logout), getmetadata, search, and getobject URLs.
Some examples are on the main project page.

bwolven gravatar imagebwolven ( 2018-08-07 09:08:27 -0600 )edit

One thing with the examples is that you need to replace the dummy class and field names with the actual ones for the MLS you are connecting to.
$results = $rets->Search('Property', 'RE_1', '(L_UpdateDate=2018-01-01+)', ['Limit' => 3, 'Select' => L_ListingID,L_Status,L_UpdateDate']);

bwolven gravatar imagebwolven ( 2018-08-07 09:17:13 -0600 )edit

You can also use www,retsmd.com to connect and look at the metadata.

bwolven gravatar imagebwolven ( 2018-08-07 09:20:32 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-08-07 15:31:44 -0600

updated 2018-08-08 04:50:27 -0600

I was able to pull URLs using this:

// Do Login - not shown

// Get URLs for these listings

$objectIds = '123,129709,130201,132738,132908,132953';

$objects = $rets->GetObject('Property', 'Photo', $objectIds, '*', 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";


// Logout of session when finished
$rets->Disconnect()

edit flag offensive delete link more

Comments

You can also query the Media resource using search to get the URLs if your account has access.
If you don't have access, you can request it through the MLS.

bwolven gravatar imagebwolven ( 2018-08-07 15:34:11 -0600 )edit

After putting some login credentials to your code I am getting these response

code: 20403 message: No object found [123:1]. getContentId: 123 getObjectId: 1 getContentType: text/xml getContent: code: 20403 message: No object found [2004701:1]. getContentId: 2004701 getObjectId: 1 getContentType: text/xml getContent: code: 20403 message: No object found [20613399:1]. getContentId: 20613399 getObjectId: 1 getContentType: text/xml getContent: code: 20403 message: No object found [2105156:1].

taminstudios gravatar imagetaminstudios ( 2018-08-08 01:41:12 -0600 )edit

getContentId: 2105156 getObjectId: 1 getContentType: text/xml getContent: code: 20403 message: No object found [21308298:1]. getContentId: 21308298 getObjectId: 1 getContentType: text/xml getContent: Object Count: 0 Object Failed Count: 5

taminstudios gravatar imagetaminstudios ( 2018-08-08 01:41:19 -0600 )edit

You would need to replace the listingIds to values for Blackhills MLS. Those were just ones from one of my test MLSs.
123 was purposely invalid on mine to show what happens with not found IDs.
I updated the example with some valid IDs from Blackhills.

bwolven gravatar imagebwolven ( 2018-08-08 04:45:48 -0600 )edit

so am I using the correct syntax to fetch the data of Individual class "RE_1" from resource "Property" with photos for each row??

$query = "(L_StatusCatID=1)";

$results = $rets->Search('Property', 'RE_1', $query, ['Limit' => 9999999]);

foreach ($results as $r) {

print_r($r->toArray());

$firstID = $r['L_ListingID'];

$photos = $rets->GetObject("Property", "Photo", $firstID,"*","1");

foreach ($photos as $photo) { $listing = $photo->getContentId(); $number = $photo->getObjectId();

taminstudios gravatar imagetaminstudios ( 2018-08-09 05:22:26 -0600 )edit

$contentText = $photo->getContent(); $success = false; if (preg_match('/replytext="SUCCESS"/i', $contentText, $match)){ // print "Match found!"; $success = true; }

    if ($success == true) {
            echo "{$listing}'s #{$number} photo is at {$photo->getLocation()}\n";
    }
    else {
            echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
    }

}

taminstudios gravatar imagetaminstudios ( 2018-08-09 05:22:50 -0600 )edit

It looks like your code should work.
Although it would be more efficient if you batched a few listings at a time instead of pulling them individually.
Is it not working for you?

bwolven gravatar imagebwolven ( 2018-08-14 09:37:24 -0600 )edit
0

answered 2018-08-07 09:32:15 -0600

taminstudios gravatar image

I did the same but I am not able to understand the schema of object or maybe I am misunderstanding.

I am able to get the data from 'Property ' resource for all classes but not getting their images.

Now I am trying to get the data from 'Media' resource for all corresponding L_ListingID's but this implementation is jerk: GetObject("Property", "Photo", "12345", "*", 1); foreach ($photos as $photo) { $listing = $photo['Content-ID']; $number = $photo['Object-ID'];

    if ($photo['Success'] == true) {
            echo "{$listing}'s #{$number} photo is at {$photo['Location']}\n";
    }
    else {
            echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
    }

}

I have changed it to: $firstID = $results->first()->get('L_ListingID'); // I WILL USE BELOW CODE INSIDE FOREACH LOOP WITH INDIVIDUAL L_ListingID.

echo $firstID; $photos = $rets->GetObject("Property", "Photo", $firstID,"*","1");

foreach ($photos as $photo) { $listing = $photo->getContentId(); $number = $photo->getObjectId();

    if ($photo['Success'] == true) {                  // NOW I AM GETTING ERROR HERE $photo['success'] is undefined.
            echo "{$listing}'s #{$number} photo is at {$photo->getLocation()}\n";
    }
    else {
            echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
    }

}

But I am not getting how to replace $photo['Success]. Really It's easy but not too much. Wasting lot of time in R&D as well as replacement of older parameters and functionalities.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-07 04:48:35 -0600

Seen: 77 times

Last updated: Aug 08