Suraj Sonawane
Suraj Sonawane

Reputation: 2494

MLS RETS Server

I am downloading property images from MLS RETS server. When I am using GetObject method to download property images, sometimes Getobject method does not return success parameter then image does not download on local server. Is any solution on it?

Here is my code :

   $photos = $rets->GetObject("Property", "Photo", $idata['propertymlsid'], "*", 0);        
    foreach ($photos as $photo) 
    {

        $imgval="";
        $imgval="{$photo['Content-ID']}-{$photo['Object-ID']}.jpg";
        if ($photo['Success'] == true) 
        {
        @file_put_contents("photos/{$photo['Content-ID']}-{$photo['Object-ID']}.jpg", $photo['Data']);
        @mysql_query("insert into tableName (pro_mlsid,photos_name,image_date)values('".$idata['propertymlsid']."','".$imgval."','".date('Y-m-d h:i:s')."')");   
        }else
        {
        // in this section i want to download image. please suggest what to do here? . i have record for this image in database for but could not download it.   
        } 

    }

please go through the code. i want to download image in else section of above code.

Upvotes: 2

Views: 817

Answers (2)

Moki
Moki

Reputation: 46

Some real estate boards allow agents to upload corrupt photos, or even invalid files (like PDFs). These mistakes made by realtors incorrectly update the RETS feed to indicate a valid photo exists, but when you attempt to download it, it fails.

Simply remove your else statement.

Upvotes: 1

Adrian World
Adrian World

Reputation: 3128

Unfortunately the RETS protocol is not made for handling images and there are quite a few pitfalls with the whole process.

  1. When an item in the database is deleted the RETS protocol is not able to reflect that change. For listings this is a very rare event but not for images. In either way there is just an error that the requested object has not been found or does not exist. In other words you have to assume that the object was deleted and you have to update your own records.

  2. Images are updated frequently by agents and may have been deleted or changed order.

  3. The image download process is twofold. a) you have to fetch the metadata record first and then b) the image itself with GetObject. However, in the meantime the agent may have deleted the image.

  4. Depending on where you get the data from there may be a lot of latency between the two events. For instance, IDX is usually a secondary database versus access to a RETS feed from the MLS itself.

So bottom line your code is probably okay but the requested image has in fact been deleted since you requested the metadata for that image.

If your process overall works and there's an image missing it may well be gone for good. In theory you should run a second process and try to fetch the actual metadata. If there's no return as well you can safely assume that the record for this image is gone.

Upvotes: 3

Related Questions