Not getting Photos in PHRETS

637 views
Skip to first unread message

Sujith Aravind

unread,
Feb 24, 2016, 8:44:40 AM2/24/16
to PHRETS
I am using  PHRETS method for pulling data from MLS server. But i am not getting images from server. Please see the full code which i am used and out put array also. 
Please help me..

Code:
<?php
$rets_login_url  = '*******';
$rets_username  = '*******';
$rets_password  = '******';
$rets_user_agent  = 'PHRETS/1.0';
$rets_user_agent_password = '********';
 
// use http://retsmd.com to help determine the SystemName of the DateTime field which
// designates when a record was last modified
$rets_modtimestamp_field = "ListDate";

// use http://retsmd.com to help determine the names of the classes you want to pull.
// these might be something like RE_1, RES, RESI, 1, etc.
$property_classes = array("1");

// DateTime which is used to determine how far back to retrieve records.
// using a really old date so we can get everything
$previous_start_time = date('Y-m-d\TH:i:s', time()-15778800);
$limit = 5;

//////////////////////////////

require_once("phrets.php");

// start rets connection
$rets = new phRETS;

$rets->AddHeader("User-Agent", $rets_user_agent);
$rets->SetParam("compression_enabled", true);
echo "+ Connecting to {$rets_login_url} as {$rets_username}<br>\n";

$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password, $rets_user_agent_password);

// check for errors
if ($connect) 
{
    echo "  + Connected<br>\n";
}
else 
{
echo "  + Not connected:<br>\n";
print_r($rets->Error());
exit;
}
foreach ($property_classes as $class) 
{
$query = "({$rets_modtimestamp_field}={$previous_start_time}+)"; 
// run RETS search
echo "   + Query: {$query}  Limit: {$limit}<br>\n";
$search = $rets->SearchQuery("Property", $class, $query, array('StandardNames' => 1,'Limit' => $limit, 'Format' => 'COMPACT-DECODED', 'Count' => 1));

if ($rets->NumRows() > 0) 
{
while ($record = $rets->FetchRow($search)) 
{
$photos = $rets->GetObject("Property","Photo",$record['ListingID'],"*",0);
echo "<pre>";
print_r($photos);
foreach ($photos as $photo) {
$listing = $photo['Content-ID'];
$number = $photo['Object-ID'];

if ($photo['Success'] == true) {
$contentType = $photo['Content-Type'];
$base64 = base64_encode($photo['Data']); 
echo "<img src='data:{$contentType};base64,{$base64}' />";
}
else {
echo "({$listing}-{$number}): {$photo['ReplyCode']} = {$photo['ReplyText']}\n";
}
}
echo "<pre>";
print_r($record);
}
$maxrows = $rets->IsMaxrowsReached();
echo "    + Total found: {$rets->TotalRecordsFound()}<br>\n";
}
}
 
    // echo "+ Disconnecting<br>\n";
    $rets->Disconnect();
?>

Output Array:


Array
(
    [0] => Array
        (
            [Success] => 
            [Content-Type] => text/xml
            [MIME-Version] => 1.0
            [Length] => 138
            [Data] => 

            [ReplyCode] => 20402
            [ReplyText] => Unknown Resource A2166184 Reference ID: 66d39fb2-446f-4c51-ab65-65010b244d50
        )

)
(-): 20402 = Unknown Resource A2166184 Reference ID: 66d39fb2-446f-4c51-ab65-65010b244d50
Array
(
    [Type] => Single Family
    [PostalCode] => 33063
    [Bedrooms] => 3
    [DaysOnMarket] => 28
    [BathsFull] => 2
    [BathsHalf] => 0
    [LivingArea] => 1580
    [ModificationTimestamp] => 2015-11-04T09:13:00
    [ListOfficeOfficeID] => KELR03
    [ListDate] => 2015-08-26T00:00:00
    [ListAgentAgentID] => 0632982
    [ListPrice] => 214900
    [ListAgentFirstName] => R. Ginenne Boehm
    [ListingID] => A2166184
    [Remarks] => Charming waterfront home 3 bedrooms,2 baths, family room,1 car garage, pool, covered screened patio, huge fenced yard, updated kitchen and baths, Freshly painted in and out!
    [ClosePrice] => 205000
    [SaleOfficeOfficeID] => KELR03
    [SaleAgentAgentID] => 0632982
    [StatusChangeDate] => 2015-11-04T09:13:00
    [ListingStatus] => Closed Sale
    [StreetName] => 77TH AV
    [StreetNumber] => 216
    [MapCoordinate] => 
    [TaxID] => 484135040310
    [City] => Margate
    [State] => Florida
    [Directions] => ATLANTIC BLVD. WEST OF ROCK ISLAND ROAD, AFTER LIGHT (78TH AVE) TURN LEFT AT 77TH AVE.
    [SaleAgentNRDSMemberID] => 
)
..........
..........

Mariano Iglesias

unread,
Feb 24, 2016, 8:49:17 AM2/24/16
to phr...@googlegroups.com
That clearly states that the resource is invalid.

Did you check the correct resource in www.retsmd.com using "View Objects"?

--
You received this message because you are subscribed to the Google Groups "PHRETS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phrets+un...@googlegroups.com.
To post to this group, send email to phr...@googlegroups.com.
Visit this group at https://groups.google.com/group/phrets.
For more options, visit https://groups.google.com/d/optout.

Sujith Aravind

unread,
Feb 25, 2016, 12:16:49 AM2/25/16
to PHRETS
Dear Mariano,

Thanks for the response. In that login i  can't find out any object id. I am passing the "ListingID" as object id. Is there any way to get sysID or Object id from  ListingID?

Gennadiy Kofman

unread,
Feb 25, 2016, 7:00:37 PM2/25/16
to PHRETS
There is usually another field for a unique id.  You didn't post all available fields, or the rets provider, so I don't know what it is for you, but for one of my rets feed that has a ListingID as the mls #, it's called ListingKey.

Sujith Aravind

unread,
Mar 3, 2016, 12:33:02 AM3/3/16
to PHRETS
Thanks for all the responses...I identified the issue. That was the issue with version. i used the 1.5 version in PHRETS...i added below line in the header and got the "sysID" and "photos".

$rets->AddHeader("RETS-Version", "RETS/1.8");

bitkahuna

unread,
May 26, 2016, 1:39:14 PM5/26/16
to PHRETS
i see no AddHeader method in phrets ??

Van Dupio

unread,
Oct 27, 2020, 8:28:39 AM10/27/20
to PHRETS
Hope I'm doing this correctly 
$objects = $rets->GetObject('Property','Photo',' L_ListingID',0,1)
["items":protected]=>
  array(1) {
    [0]=>
    object(PHRETS\Models\BaseObject)#33 (10) {
      ["content_type":protected]=>
      string(8) "text/xml"
      ["content_id":protected]=>
      string(9) "262394501"
      ["object_id":protected]=>
      string(1) "1"
      ["mime_version":protected]=>
      string(3) "1.0"
      ["location":protected]=>
      ["content_description":protected]=>
      NULL
      ["content_sub_description":protected]=>
      NULL
      ["content":protected]=>
      string(37) "<RETS ReplyCode="0" ReplyText="" />
"
      ["preferred":protected]=>
      NULL
      ["error":protected]=>
      NULL
    }
  }
}
used the L_ListingID 


I could not view the photo or download the photo

pth...@gmail.com

unread,
Nov 23, 2020, 9:11:43 AM11/23/20
to PHRETS
Hi 

Anyone know how to create wordpress websites using phrets (Real-estate website)

I want to lean can you help me please??

Thanks
Raj
Reply all
Reply to author
Forward
0 new messages