2

我正在从 MLS RETS 服务器下载属性图像。当我使用GetObject方法下载属性图像时,有时Getobject方法不返回成功参数,然后图像不会下载到本地服务器上。有什么解决办法吗?

这是我的代码:

   $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.   
        } 

    }

请通过代码。我想在上面代码的其他部分下载图像。

4

2 回答 2

3

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.

于 2015-09-30T13:45:24.040 回答
1

一些房地产委员会允许代理商上传损坏的照片,甚至是无效文件(如 PDF)。房地产经纪人犯的这些错误错误地更新了 RETS 提要以指示存在有效照片,但是当您尝试下载它时,它会失败。

只需删除您的else声明。

于 2015-11-19T22:13:36.187 回答