php - 我试图从带有 PHRETS 的 RETS 中查看照片
问题描述
这是我的代码
$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 结果获取照片的帐户 在此处输入图像描述
解决方案
有些服务器不直接提供图片,所以你需要使用他们给你的 URL:
"location":protected]=>
string(164) "http://img-st10.paragonrels.com/ParagonImages/Property/ST10/BCRES/262394501/0/0/0/08bdc26221362780ab07cb04339d48f1/15/4f9210b40832eaa2f147bb3f3378ed49/262394501.JPG"
您必须使用该 URL 来获取实际图像。
推荐阅读
- javascript - SetTimeout 在下拉菜单中第一次不起作用
- postgresql - 如何在postgresql中使用multiif
- c# - 共享库时枚举中缺少属性
- laravel - 404 和 500 异常未在 Lumen 8 中的错误视图文件上呈现
- node.js - organizations.list api 上的谷歌 Oauth 身份验证
- javascript - 如何在 Nuxt 中使用猫头鹰旋转木马?
- amazon-web-services - 允许特定用户修改特定安全组的 AWS 权限
- serialization - 在 kotlin 序列化中为多态递归类创建自定义序列化器
- api - 如何使用 Next JS 从外部 api (Heroku) 获取数据?
- microservices - 如何在不同服务之间保持 HTTP API 同步