GetObject

From PHRETS


Syntax

GetObject ( string $resource, string $type, string $id [, string $object-id [, string $location ]] )

Makes RETS request to receive objects (typically photos)


Parameters

$resource
RETS Resource for requested object
$type
RETS GetObject type. See GetMetadataObjects for available types.
$id
ID of Object. This is the value of the KeyName field within the Resource for your record (typically the MLS#). This is NOT the full ID as described in the RETS specification.
$object-id
Optional. Requested object ID. Typically represents the photo order.
Possible Values: 0, 1, 2, 3, etc., or * (asterisk) to request all objects. Default is *
$location
Optional. Used to return URLs rather than image data. Not always supported by the server. 1 is True (get URLs), 0 is False (get binary image data). Default is 0.

Return Values

Array
Each item in this array represents a single image that was returned. If multiple images requested, multiple array keys exist and the server may return these in any order.
Possible item contents:
Success - Boolean. True if the specific response is successful. False if not.
Content-ID - Content-ID for this specific object.
Object-ID - Object-ID for this specific object (typically represents the display order)
Content-Type - Content-Type for this specific object.
MIME-Version - MIME-Version of this object.
Content-Description - Text description of this object.
Location - Returned if Location is True and server supports. Contains URL to object
Length - Size of data response
Data - Contains the response. If requested Location as False, this is raw image data.
ReplyCode - If Success is False, this contains the RETS ReplyCode returned.
ReplyText - If Success is False, this contains the RETS ReplyText returned.


Changelog

Version Description
1.0 Added more intelligent support for multiple id's or object-id's


Examples

Pulls all photos for 12345
$photos = $rets->GetObject("Property", "Photo", "12345");
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";
        }
}
Pulls all photo URLs for 12345
$photos = $rets->GetObject("Property", "Photo", "12345", "*", 1);
foreach ($photos as $photo) {
        $listing = $photo['Content-ID'];
        $number = $photo['Object-ID'];

        if ($photo['Success'] == true) {
                echo "{$listing}'s #{$number} photo is at {$photo['Location']}\n";
        }
        else {
                echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
        }
}
Pull URL for 12345's #2 photo
$photos = $rets->GetObject("Property", "Photo", "12345", "2", 1);
foreach ($photos as $photo) {
        $listing = $photo['Content-ID'];
        $number = $photo['Object-ID'];

        if ($photo['Success'] == true) {
                echo "{$listing}'s #{$number} photo is at {$photo['Location']}\n";
        }
        else {
                echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
        }
}
Pull URLs for 12345, 12346 and 12347's 3rd, 4th and 5th photos each
$photos = $rets->GetObject("Property", "Photo", "12345,12346,12347", "3,4,5", 1);
foreach ($photos as $photo) {
        $listing = $photo['Content-ID'];
        $number = $photo['Object-ID'];

        if ($photo['Success'] == true) {
                echo "{$listing}'s #{$number} photo is at {$photo['Location']}\n";
        }
        else {
                echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
        }
}


Related to

Views
Personal tools
Navigation
download
documentation
random wiki fun
Toolbox