Is it possible to get all photo locations with properties when querying a RETS server using DMQL2?

844 views Asked by At

I would like to download all property listings from a RETS server, including all photo URLs. I'm using DMQL2 and the PHRETS library. Properties and photo objects are stored in the RETS server in different tables.

To get all the photos, I know I can download the list of properties, then loop through each and retrieve the photos for each property like this:

$results = $rets->Search($resource, $class, $query);
foreach ($results as $r) {
    $photos = $rets->GetObject('Property', 'Photo', $r->get('ListingID'), '*', 1);
    foreach ($photos as $p) {
        // Save the photo locations somewhere…
    }
}

This is incredibly slow because there are many thousands of properties.

Is it possible to request all photos along with properties in a single query by joining the property and object tables (like a LEFT JOIN in MySQL)?

Or, is there a way to download all photo objects in one request, so I can correlate them to properties using their ListingID key?

Any other suggestions for getting all the data more quickly?

2

There are 2 answers

0
V-T On BEST ANSWER

Partially possible, but then currently can't download entire photos along with properties in a single query.

We can download multiple listing's images in a single query. Check the sample query below.

$photos = $rets->GetObject("Property", "Photo", "12345,12346,12347", "*", 1);
foreach ($photos as $p) {
    $listingId = $p['Content-ID']; // save photo based on each listingIds
    //continue
}

Here 3rd parameter we can provide comma separated listingIds. Thereby you can pass the listingIds as batches.

Note: Still MLS holds the extraction speed. Some MLS boards may increase the bandwidth temporarily on request. Within that time try to extract full images.

1
slim On

You can download all the photos at once. Some servers also support media resources and classes that allow you to get the URLs to all the photos for a listing or group of listings. If your server supports that, I would use it because it's typically faster.

Using phrets, I think downloading all the images at one time looks like this:

$photos = $rets->GetObject("Property", "Photo", $record[ListingID], "*", 1);

I copied that from this SO answer: PHRets: Using PHP to download real estate listing photos