背景资料
- 我想使用 PHPRETS 下载特定属性的照片。
- 我的 PHPRETS 配置成功地下载了属性数据。问题仅在于下载媒体文件。
- 我可以使用 Windows 应用程序 RETS 连接器下载该物业的照片,这意味着图像存在。
- 我作为对象键 (N3273704) 传递的值是我从 KeyField (ml_num) 获得的值
关键字段
ml_num
我运行的代码
$photos = $rets->GetObject("Property", "Photo", "N3273704", "*", 0);
var_dump($photos);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];
if ($photo['Success'] == true) {
file_put_contents("image-{$listing}-{$number}.jpg", $photo['Data']);
} else {
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
}
}
原始标头和响应
[2015-07-29 13:16:09] PHRETS.DEBUG: Sending HTTP Request for http://rets.torontomls.net:6103/rets-treb3pv/server/getobject (GetObject) {"query":{"Resource":"Property","Type":"Photo","ID":"N3273704:*","Location":0},"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.5","Accept-Encoding":"gzip"},"cookies": ..."]} []
[2015-07-29 13:16:09] PHRETS.DEBUG: Response: HTTP 200 [] []
屏幕输出(var_dump 的结果)
array(20) {
[0]=>
object(PHRETS\Models\Object)#32 (10) {
["content_type":protected]=>
string(8) "text/xml"
["content_id":protected]=>
string(4) "null"
["object_id":protected]=>
string(4) "null"
["mime_version":protected]=>
NULL
["location":protected]=>
NULL
["content_description":protected]=>
NULL
["content_sub_description":protected]=>
NULL
["content":protected]=>
string(192) "<?xml version="1.0" standalone="no"?>
<!DOCTYPE RETS SYSTEM "RETS-20041001.dtd">
<RETS ReplyCode="20403" ReplyText="No Object Found: No matching object was found to satisfy the request."/>"
["preferred":protected]=>
NULL
["error":protected]=>
object(PHRETS\Models\RETSError)#45 (2) {
["code":protected]=>
int(20403)
["message":protected]=>
string(69) "No Object Found: No matching object was found to satisfy the request."
}
}
[1]=> ...