First time here? Check out the FAQ!
0

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

  • retag add tags

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.

taminstudios's avatar
taminstudios
asked 2018-08-09 07:57:44 -0500, updated 2018-08-09 08:02:40 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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.

bwolven's avatar
bwolven
answered 2018-08-13 10:45:39 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Login/Signup to Answer