Ask Your Question

Do I need to fetch individual Class from Resource "Property" than same class from Resource "Media" to get respective photos of individual row?

asked 2018-08-09 07:57:44 -0600

updated 2018-08-09 08:02:40 -0600

I wrote this code

$query = "(L_StatusCatID=1)";

$results = $rets->Search('Property', 'RE_1', $query, ['Limit' => 9999999]);

foreach ($results as $r) { print_r($r->toArray());

$firstID = $r['L_ListingID'];

$photos = $rets->GetObject("Property", "Photo", $firstID,"*","1");

foreach ($photos as $photo) { // $photo = (array) $photo; // var_dump($photo->getContent());die; //var_dump($photo->getContentId()); $listing = $photo->getContentId(); $number = $photo->getObjectId(); $contentText = $photo->getContent(); $success = false; if (preg_match('/replytext="SUCCESS"/i', $contentText, $match)){ // print "Match found!"; $success = true; }

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


If I am working right then please let me know should I use Property Classes as main category and L_Type_ as subcategory for individual class. I saw too many L_Type_ in a single class and they are helpful in categorization of property please info me if someone has updated PHRETS 1.8 and API implementation to it's latest version.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-13 10:45:39 -0600

When querying the media resource, use the same class as property to pull the image URLs.
Using your example above it would be:
$query = "(L_StatusCatID=1)";
$results = $rets->Search('Media', 'RE_1', $query, ['Limit' => 9999999]);

Using GetObject() like your example above, it only takes the resource (not class specific).
I would suggest that you don't pull a single listing's images at once if at all possible, except for testing purposes.
Pull them in batches of 5, 10 or more at a time to reduce server overhead.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-09 07:57:44 -0600

Seen: 411 times

Last updated: Aug 13 '18