Accessing photos
Retrieving photo records is done by submitting a query to the Media resource. Our server does not support GetObject requests to access photos.
Fields
The Media resouce has the following fields:
Field Name | Description |
---|---|
listno | listing number |
caption | photo caption |
catagory | type of media resource |
lastmod | date/time record was modified |
name | photo name |
place | order of the photo |
title | photo title |
ts | date/time record was modified |
url | URL of the photo on the internets |
GetObject support
GetObject is limited to only requests that include the Location=1 parameter. If you do not inclued Location=1 in your request the server will assume you mean Location=0 and you will receive the following error:
<RETS ReplyCode="20409" ReplyText="Object Unavailable" />
Primary photo
Each class in the Property resource has an "image" field. This field is a String and contains the name of the primary photo. To be able to use create a URL to the photo you must decided which size you would like to display and then use that information to create the full URL.
Available photos sizes:
- 65x50
- 105x79
- 280x210
- 640x480
The full URL is created as by concatenating "http://assets.utahrealestate.com/photos/" + size + name
If the primary photo name is "1419192_7ce8c637d1b607e8aa4077c952f62f2c_137605.jpg" and you want to the 280x210 size the URL would be http://assets.utahrealestate.com/photos/280x210/1419192_7ce8c637d1b607e8aa4077c952f62f2c_137605.jpg
Photo names
The name of the photos are unique and will change with any update to the photo. This will prevent the photo from being cached by web browsers. The photo names are created by appending a unique string after the listing number (listno + '_' + UNIQUE_STRING + '.jpg').
Hot-linking photos
It is a good idea to hot-link the photos to our server. This will prevent any need for you to download every photo and keep them in sync. All you will need to do is keep track of the URLs associated with each liting.
You can use the "name" field from the Media resource to create a link to any of the available photo sizes. Just concatenate "http://assets.utahrealestate.com/photos/" + size + name.
Photo order
Use the "place" field from the Media resource to display listings in the right order. The "place" field is an Int field. Photos should be displayed by using the "place" value in ascending order. A "place" value of "0" means that that is the primary photo. Any record with a place value greater then "0" is a secondary photo.
Pulling photos secondary photos
After retrieving data for a class in the Property resource you can check to see if you need to pull photos for each listing. Each record has a photocount field. That field contains the number of photo URLs associated with that listing. If the field is greater then "1" it has secondary photos. Make a request to the server to retrieve all of the photo records for each listing that has secondary photos.
Keeping photos in sync
Each class in the Property resource has a dtphoto field. That is the date and time that any of the associated photos were updated. Use that field and not the "dtlastmod" or "ts" field on the Property class to decide which photos records to download. If you use the "dtlastmod" or "ts" fields from the Property class you will be downloading too much data. The Media class in the Media resource has over 10 million records. There is no reason to download them all.
This is an example of pulling inremental record changes and the associated media records.
Step 1 - get property class records that have changed since your last pull
Request:
GET /contact/rets/search?SearchType=Property&Class=tt_res&Query=%28dtlastmod%3D2017-01-09T14%3A30%3A00%2B%29&QueryType=DMQL2&Count=1&Format=COMPACT-DECODED&Limit=99999999&StandardNames=0 HTTP/1.1
Authorization: Digest username="YOURUSERNAME", realm="rets@retsiq.com", nonce="faa78c8fc29709f6df15900fd41ee632", uri="/contact/rets/search?SearchType=Property&Class=tt_res&Query=%28dtlastmod%3D2017-01-09T14%3A30%3A00%2B%29&QueryType=DMQL2&Count=1&Format=COMPACT-DECODED&Limit=99999999&Select=ListNo%2C+dtlastmod%2C+dtphoto%2C+status%2Cts&StandardNames=0", cnonce="MTQ4Mzk5", nc=00000003, qop="auth", response="a3d1db91f507e6efe611cf35b8afb520", opaque="481379ef6fbdc"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=C776EBBDB13D33B04348A85BE78036E9; RETS-Session-ID=5960097b7e0abdeb5e23796b864c227215985242dbf; JSESSIONID=C776EBBDB13D33B04348A85BE78036E9
Accept: */*
RETS-Version: RETS/1.8
User-Agent: PHRETS/1.0
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=C776EBBDB13D33B04348A85BE78036E9; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-Type: text/xml
Content-Length: 1394
Date: Mon, 09 Jan 2017 21:30:57 GMT
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<COUNT Records="13" />
<DELIMITER value="09" />
<COLUMNS> ListNo dtlastmod dtphoto status ts</COLUMNS>
<DATA> 1379323 2017-01-09T14:30:15 2016-11-11T11:55:21 Under Contract 2017-01-09T14:30:15</DATA>
<DATA> 1424371 2017-01-09T14:30:28 2017-01-03T12:28:26 Active 2017-01-09T14:30:28</DATA>
<DATA> 1424627 2017-01-09T14:30:31 2017-01-09T14:30:31 Active 2017-01-09T14:30:31</DATA>
<DATA> 1423138 2017-01-09T14:31:05 2016-12-18T21:11:52 Active 2017-01-09T14:31:05</DATA>
<DATA> 1422314 2017-01-09T14:31:26 2016-12-12T12:11:40 Under Contract 2017-01-09T14:31:26</DATA>
<DATA> 1308835 2017-01-09T14:31:57 2015-12-22T11:30:05 Active 2017-01-09T14:31:57</DATA>
<DATA> 1396440 2017-01-09T14:32:09 2016-07-27T11:15:06 Active 2017-01-09T14:32:09</DATA>
<DATA> 1425074 2017-01-09T14:32:28 2017-01-09T14:30:12 Active 2017-01-09T14:32:28</DATA>
<DATA> 1227233 2017-01-09T14:33:02 1973-01-04T12:19:49 Under Contract 2017-01-09T14:33:02</DATA>
<DATA> 1361487 2017-01-09T14:33:02 2016-08-11T10:00:07 Under Contract 2017-01-09T14:33:02</DATA>
<DATA> 1386171 2017-01-09T14:33:02 2016-07-14T14:45:48 Active 2017-01-09T14:33:02</DATA>
<DATA> 1399939 2017-01-09T14:33:02 2016-08-11T10:00:07 Active 2017-01-09T14:33:02</DATA>
DATA> 1417301 2017-01-09T14:33:02 2016-11-05T15:59:10 Under Contract 2017-01-09T14:33:02</DATA>
</RETS>
Step 2 - loop through the results and see if the dtphoto is greater than the media date that you have for this listing
while still have RETS query results
set listingnumber = results listno
select max time stamp from local data store where key is listingnumber
if max time stamp is less than dtphoto OR max time stamp is null
query media resource where listno = listingnumber and dtphoto > max time stamp
else
skip record
Following these steps will keep your media (photo) records up today without pulling any unnessecery data.
Note: You can pull media records for a group of listings in one query by using the OR operator like this (listno=|1234567,1234568,1234569)