简体   繁体   中英

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

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?

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.

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

Using GetObject function, It's not possible to get images of more than one listing in a request. However, you can send a request on Media Resource and get images of more than one listing, if MLS Server support that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM