0

这是我的代码
$objects = $rets->GetObject('Property','Photo','262394501','*',0);

foreach ($objects as $object)
{      
        $contentType=$object->GetcontentType();
        $base64 = base64_encode($object->Data());
echo "<img src='data:{$contentType};base64,{$base64}' />";
}

结果致命错误:未捕获错误:调用未定义的方法 PHRETS\Models\BaseObject::Data()

$objects 的 var_dump

...
 [19]=>
    object(PHRETS\Models\BaseObject)#87 (10) {
      ["content_type":protected]=>
      string(8) "text/xml"
      ["content_id":protected]=>
      string(9) "262394501"
      ["object_id":protected]=>
      string(2) "20"
      ["mime_version":protected]=>
      NULL
      ["location":protected]=>
      NULL
      ["content_description":protected]=>
      NULL
      ["content_sub_description":protected]=>
      NULL
      ["content":protected]=>
      string(77) "<RETS ReplyCode="20409" ReplyText="Object Unavailable [262394501:20]." />

"
      ["preferred":protected]=>
      NULL
      ["error":protected]=>
      object(PHRETS\Models\RETSError)#96 (2) {
        ["code":protected]=>
        int(20409)
        ["message":protected]=>
        string(34) "Object Unavailable [262394501:20]."
      }
    }

 $objects = $rets->GetObject('Property','Photo','262394501','*',1);
    var_dump($objects);

....
[19]=>
    object(PHRETS\Models\BaseObject)#72 (10) {
      ["content_type":protected]=>
      string(8) "text/xml"
      ["content_id":protected]=>
      string(9) "262394501"
      ["object_id":protected]=>
      string(2) "20"
      ["mime_version":protected]=>
      NULL
      ["location":protected]=>
      string(168) "http://img-st10.paragonrels.com/ParagonImages/Property/ST10/BCRES/262394501/19/0/0/4cf9ac732b4cae04d8664c68e65e8d79/15/4f9210b40832eaa2f147bb3f3378ed49/262394501-19.JPG"
      ["content_description":protected]=>
      NULL
      ["content_sub_description":protected]=>
      NULL
      ["content":protected]=>
      string(59) "<RETS ReplyCode="0" ReplyText="Operation Successful" />

"
      ["preferred":protected]=>
      NULL
      ["error":protected]=>
      NULL
    }
  }

$objects = $rets->GetObject('Property','Photo','262394501',1,1);
var_dump($objects);
object(Illuminate\Support\Collection)#40 (1) {
  ["items":protected]=>
  array(1) {
    [0]=>
    object(PHRETS\Models\BaseObject)#33 (10) {
      ["content_type":protected]=>
      string(8) "text/xml"
      ["content_id":protected]=>
      string(9) "262394501"
      ["object_id":protected]=>
      string(1) "1"
      ["mime_version":protected]=>
      string(3) "1.0"
      ["location":protected]=>
      string(164) "http://img-st10.paragonrels.com/ParagonImages/Property/ST10/BCRES/262394501/0/0/0/08bdc26221362780ab07cb04339d48f1/15/4f9210b40832eaa2f147bb3f3378ed49/262394501.JPG"
      ["content_description":protected]=>
      NULL
      ["content_sub_description":protected]=>
      NULL
      ["content":protected]=>
      string(37) "<RETS ReplyCode="0" ReplyText="" />
"
      ["preferred":protected]=>
      NULL
      ["error":protected]=>
      NULL
    }
  }
}

没有找到数据数组,这意味着我无法获取照片并使用 L_ListingID 结果获取照片的帐户 在此处输入图像描述

4

1 回答 1

0

有些服务器不直接提供图片,所以你需要使用他们给你的 URL:

"location":protected]=>
  string(164) "http://img-st10.paragonrels.com/ParagonImages/Property/ST10/BCRES/262394501/0/0/0/08bdc26221362780ab07cb04339d48f1/15/4f9210b40832eaa2f147bb3f3378ed49/262394501.JPG"

您必须使用该 URL 来获取实际图像。

于 2020-10-29T12:42:05.847 回答