Giter Site home page Giter Site logo

troydavisson / phrets Goto Github PK

View Code? Open in Web Editor NEW
445.0 62.0 235.0 462 KB

PHP client library for interacting with a RETS server to pull real estate listings, photos and other data made available from an MLS system

Home Page: http://troda.com

License: MIT License

PHP 100.00%
php mls phrets client-library

phrets's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phrets's Issues

How to find the object types for photos?

I can use GetMetadataTypes() to find my resources and classes, but there is no indication of where the photos are. If I use GetMetadataObjects('Property') it shows Photos, but how do I get the types for use with GetObject()? Specifically, the second parameter takes a value that is called $type, but I am not finding a way to check what the types are. I am probably just overlooking something. Thanks for your work!

PHRETS with laravel 5

Please can you revert the container/support version requirements in master to >=

        "illuminate/container": ">=4.2.0",
        "illuminate/support": ">=4.2.0"

phrets class not working over server

Hello,

Sorry for my english.

I am using http://retsgw.flexmls.com API to fetch properties.

I used phrets.php class to do this.

Code working fine on local machine but when i uploaded it to server it gives error and nothing is working. The exact error is :

Array
(
[type] => rets
[code] => 20500
[text] => RETS Server: Required parameter (ID) was not supplied. See: http://flexmls.com/rets/e/9
)

Please help me out this.
Thanks in advance.

Query Issue:

As I am new to PHRETS, I used It and able to make connection.
I also get property data when used query as:-

$search = $rets->SearchQuery("Property","ResidentialProperty","(Ml_num=W2597030)",
array( "Count" => 1, "Format" => "COMPACT", "Offset" => "1")
);

OR

$search = $rets->SearchQuery("Property","ResidentialProperty","(Status=A)",
array( "Count" => 1, "Format" => "COMPACT", "Limit" => "3", "Offset" => "1")
);

But Now I need to run query for a specific "Link broker"... For this I used to run query as:

$search = $rets->SearchQuery("Property","ResidentialProperty","(Rltr=*)",
array( "Count" => 1, "Format" => "COMPACT", "Limit" => "3", "Offset" => "1")
);

When Used to run this query i got this error msg:-
Array ( [type] => rets [code] => 20202 [text] => Invalid Select: The Select statement contains field names that are not recognized by the server. )

Note:- My property broker name is already listed in list. when I used to download property for their specific MLS#.

Thanks

Error When trying to activate

Notice: Undefined index: scheme in phRETS->Connect() (line 1370 of /homepages/2/d179335834/htdocs/RyenBE/sites/all/libraries/phrets/phrets.php).
Notice: Undefined index: scheme in phRETS->Connect() (line 1371 of /homepages/2/d179335834/htdocs/RyenBE/sites/all/libraries/phrets/phrets.php).
drealty encountered an error: (Type: http Code: 0 Msg: )

Help?

MAX ROWS with offset

Murphy's Law is in play, and my RETS server has a result set that returns a total set size that is an exact multiple of MAX ROWS. So, MAX ROWS is 500, and the total result set is 2000, necessitating four batches in SearchQuery. The problem is that on the last batch, MAX ROWS is set by the server, but it's also the last possible result set because and offset value of 2001 will return an offset error from the RETS server. Based on how maxrows_reached is set, the query always errors out with this data set, because it always tries to request one more batch than necessary.

My rather ham-fisted fix is:

if (isset($xml->MAXROWS)) {
// MAXROWS tag found. the RETS server withheld records.
// if the server supports Offset, more requests can be sent to page through results
// until this tag isn't found anymore.
if(isset($xml->COUNT)) {
// Check to see if this is the last batch based on the total size of the result set. Server may set MAX ROWS even if this
// batch is the last possible set, if the total records found is perfectly divisible by max rows.
if($this->NumRows($this->int_result_pointer) < $this->search_data[$this->int_result_pointer]['total_records_found']) {
$this->search_data[$this->int_result_pointer]['maxrows_reached'] = true;
}
} else {
$this->search_data[$this->int_result_pointer]['maxrows_reached'] = true;
}
}

Not knowing enough about the internals of phRETS I didn't want to do a pull request, as I thought this is probably not the optimal solution.

Beginning the Build of the Database

So as I enter the beginning stages of the database build. I am ooking for the best and least redundant way of updating and adding new properties to the DB. Originally I plan on importing the past data into it. After that is complete I just wanted to update and insert new properties and info.

I found a field called "RECORDMODDATE" (ModificationTimestamp). I am assuming that this is changed upon any change made to the listing/record. I will have to verify this with my MLS provider. Ideally that will include all status entry's or modifications.

My intentions are to simply update and/or insert (if mls doesn't exist) my database on a daily or multi-daily basis but only the record/listing that were modified on that date.

Any thoughts or tips before proceeding.

Running out of memory for HUGE feeds (solved but wanted to share)

OK should say I love phrets and use it quite often but for a while when it comes to a very very large feed I always get a "OUT OF MEMORY ERROR" for months I changed how I parsed the data so it came to phrets as smaller chunks. BUT today I happen to notice that the error I was getting was with preg_replace and since preg_replace is knows to have memory leaking issues I thought I would look into it.

turns out not only does pre_replace not like large amounts of data either does the utf8_encode() function

so line 1535 is:

$data = preg_replace('/&(?!\w+;)/', '&', $data);

I CHANGED TO:

                    //jim start\\
        $myStrLen = strlen($data);
        if ( $myStrLen > 4096 ){
            $howManySplits = $myStrLen/4096;
            $howManySplits = ceil($howManySplits);
            //  echo "\n $myStrLen / $howManySplits \n";
            $l_instr = "";
            for ($i = 0; $i < $howManySplits; $i++) {
                $startchunk = $i*4096;
                $chunk = substr($data,$startchunk,4096);
                $chunk = preg_replace('/\&\s/', '&amp; ', $chunk);
                $l_instr .= $chunk;
                unset($chunk);
            }
            $data = $l_instr;
        }else{
            $data = preg_replace('/\&(?!\w+\;)/', '&amp;', $data);
        }
        //jim end\\

on line 1742

$in_str = preg_replace('/&\s/', '& ', $in_str);

I CHANGED TO:

//jim start
$myStrLen = strlen($in_str);
if ( $myStrLen > 4096 ){
$howManySplits = $myStrLen/4096;
$howManySplits = ceil($howManySplits);
// echo "\n $myStrLen / $howManySplits \n";
$l_instr = "";
for ($i = 0; $i < $howManySplits; $i++) {
$startchunk = $i*4096;
$chunk = substr($in_str,$startchunk,4096);
$chunk = preg_replace('/&\s/', '& ', $chunk);
// echo "\n $chunk \n";
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) {
//return $in_str;
$l_instr .= $chunk;
}else {
$l_instr .= utf8_encode($chunk);
}
unset($chunk);
}
return $l_instr;
}else{
$in_str = preg_replace('/&\s/', '& ', $in_str);
if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) {
return $in_str;
}else{
return utf8_encode($in_str);
}
}
//jim end\

This all seems to be working for me without the memory issues. I would suspect others are having a similar issue but have found ways around it. This seems to be a way not to have to "go around it"

thanks,
Jim
phrets1
phrets2

Large datasets can cause xml parsing error

Depending on the version of libxml2, I've found that a very large dataset can cause an XML parse error, and zero records processed. I think one easy solution is to pass the LIBXML_PARSEHUGE to the @simplexml_load_string function.
i.e. on line 1539:

$xml =  @simplexml_load_string($data, 'SimpleXmlElement', LIBXML_PARSEHUGE );

Limit Default - forcing bad behavior on servers

Change can be viewed at:
doapp-pete@dd2e47c

$search_arguments['Limit'] = empty($optional_params['Limit']) ? 99999999 : $optional_params['Limit'];

should be replaced to be

if(!empty($optional_params['Limit'])){
    $search_arguments['Limit'] = $optional_params['Limit'];
}

to resolve issue which was forcing a 5000 limit if any limit was set at all on rets 1.7.2 and 1.8.0 servers.

SQL Tables

Hello, Create_tables_from_sql is not completely replicating the fields. Most of the fields are missing which cause values to be mismatch.

Feature request: proxy

PHRETS is working great for me. Unfortunately, my RETS provider institutes an IP restriction. As I am on a long road trip and connecting from different locations every single day, this is prohibitive for me. I set up my own proxy system, such that I can connect to a remote server, which will relay the connection via the server with the IP known to the RETS provider. This works well for one RETS provider, but not another. The second one doesn't work because in the authentication process, it provides URIs that PHRETS honors. I don't want it to honor those URIs. Instead, I'd like to replace the domains with my own proxy's domain, and all will be good.

For example, if I would normally connect to retssystem.com, I want to set up my proxy on retsproxy.myserver.com to proxy to retssystem.com. When retsystem.com replies during the authentication process and says "use URI http://retssystem.com/XYZ", I want PHRETS to replace the URI base/domain and use http://retsproxy.myserver.com/XYZ.

Can it be done?

use classmap or PSR0 instead of files autoloading?

Composer generates auto-loading automatically and there is usually whole bunch of otther libraries like Zend or Symfony. PHRETS is not necessarily needed on each request yet as of now it's required by composer's auto-loader along with each request.

IMHO - it would make sense to use either "classmap" or "PSR 0" type auto loading - so users would only load and PHRETS file when needed...

Documentation deprecated

Been trying to follow examples in the wiki, but a lot of functions are undefined. Is this because the documentation isn't up to date or are they ok and it's just me doing all the wrong way?

Cannot get data with Standard-XML format query

Hi there,

I'm trying to access the Rets data using Standard-XML but Phrets 1.0.1 is not returning any data. This is opposed to using Compact-Decoded which works great.

To illustrate the problem, I'm using your CSV output sample code from the wiki. Below is that sample PHP code as well as the plain XML data that I've been able to access by logging the last request.

If you need my rets / crea credentials, happy to share them privately through email.

Thanks for your help.

<?php

$rets_login_url = "http://data.crea.ca/Login.svc/Login";
$rets_username = ""; // redacted
$rets_password = ""; // redacted

// Sample data
//$rets_login_url = 'http://sample.data.crea.ca/Login.svc/Login';
//$rets_username = 'CXLHfDVrziCfvwgCuL8nUahC';
//$rets_password = 'mFqMsCSPdnb5WO1gpEEtDCHH';

// 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("Property");

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

require_once("phrets.php");

// start rets connection
$rets = new phRETS;

echo "+ Connecting to {$rets_login_url} as {$rets_username}<br>\n";
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password);

if ($connect) {
        echo "  + Connected<br>\n";
}
else {
        echo "  + Not connected:<br>\n";
        print_r($rets->Error());
        exit;
}

foreach ($property_classes as $class) {

        echo "+ Property:{$class}<br>\n";

        $file_name = strtolower("property_{$class}.csv");
        $fh = fopen($file_name, "w+");

        $maxrows = true;
        $offset = 1;
        $limit = 'None';
        $fields_order = array();

        while ($maxrows) {

                //$query = "ID=*";
                $query = "ID=13560156";

                // run RETS search
                echo "   + Query: {$query}  Limit: {$limit}  Offset: {$offset}<br>\n";
                $search = $rets->SearchQuery("Property", $class, $query, array('Limit' => $limit, 'Offset' => $offset, 'Format' => 'STANDARD-XML', 'Count' => 1));

                if ($rets->NumRows() > 0) {

                        if ($offset == 1) {
                                // print filename headers as first line
                                $fields_order = $rets->SearchGetFields($search);
                                fputcsv($fh, $fields_order);
                        }

                        // process results
                        while ($record = $rets->FetchRow($search)) {
                                $this_record = array();
                                foreach ($fields_order as $fo) {
                                        $this_record[] = $record[$fo];
                                }
                                fputcsv($fh, $this_record);
                        }

                        $offset = ($offset + $rets->NumRows());

                }

                $maxrows = $rets->IsMaxrowsReached();
                echo "    + Total found: {$rets->TotalRecordsFound()}<br>\n";

                $rets->FreeResult($search);
        }

        fclose($fh);

        echo "  - done<br>\n";

}

echo "+ Disconnecting<br>\n";
$rets->Disconnect();

Sample XML data:

<?xml version="1.0" encoding="UTF-8"?>
<RETS ReplyCode="0" ReplyText="Operation successful">
    <RETS-RESPONSE xmlns="CREA.Search.Property">
        <Pagination>
            <TotalRecords>1</TotalRecords>
            <Limit>10</Limit>
            <Offset>1</Offset>
            <TotalPages>1</TotalPages>
            <RecordsReturned>1</RecordsReturned>
        </Pagination>
        <PropertyDetails ID="13560156" LastUpdated="Mon, 09 Sep 2013 13:42:14 GMT">
            <ListingID>1306586</ListingID>
            <AgentDetails ID="1460791">
                <Name>PEGGY HILL</Name>
                <Phones>
                    <Phone ContactType="Business" PhoneType="Telephone">(705) 739-4455</Phone>
                    <Phone ContactType="Business" PhoneType="Fax">(705) 733-2200</Phone>
                </Phones>
                <Websites>
                    <Website ContactType="Business" WebsiteType="Website">http://peggyhill.com/content/listings2</Website>
                    <Website ContactType="Business" WebsiteType="FaceBook">http://www.facebook.com/ThePeggyHillTeamBarrie</Website>
                    <Website ContactType="Business" WebsiteType="LinkedIn">http://www.linkedin.com/company/peggy-hill-&amp;-associates-realty-inc</Website>
                    <Website ContactType="Business" WebsiteType="Twitter">HTTP://TWITTER.COM/#!/PEGHILLREALTOR</Website>
                </Websites>
                <Office ID="272203">
                    <Name>KELLER WILLIAMS EXPERIENCE REALTY, BROKERAGE</Name>
                    <Address>
                        <StreetAddress>431 HURONIA ROAD|UNIT 13</StreetAddress>
                        <AddressLine1>431 HURONIA ROAD</AddressLine1>
                        <Addressline2>UNIT 13</Addressline2>
                        <City>BARRIE</City>
                        <PostalCode>L4N9B3</PostalCode>
                    </Address>
                    <Phones>
                        <Phone ContactType="Business" PhoneType="Telephone">(705) 720-2200</Phone>
                        <Phone ContactType="Business" PhoneType="Fax">(705) 733-2200</Phone>
                    </Phones>
                    <Websites>
                        <Website ContactType="Business" WebsiteType="Website">http://www.KW-Experience.com</Website>
                    </Websites>
                </Office>
                <Position>Broker</Position>
            </AgentDetails>
            <AgentDetails ID="1452910">
                <Name>TERRY LAYCOCK SCHNEIDER</Name>
                <Phones>
                    <Phone ContactType="Business" PhoneType="Telephone">(705) 791-8911</Phone>
                    <Phone ContactType="Business" PhoneType="Fax">(705) 733-2200</Phone>
                </Phones>
                <Websites>
                    <Website ContactType="Business" WebsiteType="Website">http://www.yourhomeline.com</Website>
                </Websites>
                <Office ID="272203">
                    <Name>KELLER WILLIAMS EXPERIENCE REALTY, BROKERAGE</Name>
                    <Address>
                        <StreetAddress>431 HURONIA ROAD|UNIT 13</StreetAddress>
                        <AddressLine1>431 HURONIA ROAD</AddressLine1>
                        <Addressline2>UNIT 13</Addressline2>
                        <City>BARRIE</City>
                        <PostalCode>L4N9B3</PostalCode>
                    </Address>
                    <Phones>
                        <Phone ContactType="Business" PhoneType="Telephone">(705) 720-2200</Phone>
                        <Phone ContactType="Business" PhoneType="Fax">(705) 733-2200</Phone>
                    </Phones>
                    <Websites>
                        <Website ContactType="Business" WebsiteType="Website">http://www.KW-Experience.com</Website>
                    </Websites>
                </Office>
                <Position>Broker</Position>
            </AgentDetails>
            <Board>17</Board>
            <Business>
                <Franchise>False</Franchise>
            </Business>
            <Building>
                <BathroomTotal>3</BathroomTotal>
                <BedroomsTotal>2</BedroomsTotal>
                <Age>11 to 20 years</Age>
                <Appliances>Jacuzzi, Central Vacuum, Water softener</Appliances>
                <BasementDevelopment>Finished</BasementDevelopment>
                <BasementType>Full</BasementType>
                <ConstructedDate>10 years</ConstructedDate>
                <ConstructionStyleAttachment>Detached</ConstructionStyleAttachment>
                <CoolingType>Central air conditioning</CoolingType>
                <DisplayAsYears>1</DisplayAsYears>
                <ExteriorFinish>Brick</ExteriorFinish>
                <FireplaceFuel>Gas</FireplaceFuel>
                <FireplacePresent>True</FireplacePresent>
                <FireplaceType>Conventional</FireplaceType>
                <Fixture>Drapes/Window coverings</Fixture>
                <FlooringType>Hardwood, Laminate</FlooringType>
                <FoundationType>Poured Concrete</FoundationType>
                <HeatingFuel>Natural gas</HeatingFuel>
                <HeatingType>Forced air,Radiant heat</HeatingType>
                <Rooms>
                    <Room>
                        <Type>Living room</Type>
                        <Width>5.31 m</Width>
                        <Length>3.64 m</Length>
                        <Level>Second level</Level>
                        <Dimension>3.64 m x 5.31 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Dining room</Type>
                        <Width>4.15 m</Width>
                        <Length>3.64 m</Length>
                        <Level>Second level</Level>
                        <Dimension>3.64 m x 4.15 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Kitchen</Type>
                        <Width>2.22 m</Width>
                        <Length>3.53 m</Length>
                        <Level>Second level</Level>
                        <Dimension>3.53 m x 2.22 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Master bedroom</Type>
                        <Width>5.47 m</Width>
                        <Length>3.63 m</Length>
                        <Level>Second level</Level>
                        <Dimension>3.63 m x 5.47 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Full ensuite bathroom</Type>
                        <Width />
                        <Length />
                        <Level>Second level</Level>
                        <Dimension>n/a</Dimension>
                    </Room>
                    <Room>
                        <Type>Bedroom 2</Type>
                        <Width>3.22 m</Width>
                        <Length>4.27 m</Length>
                        <Level>Second level</Level>
                        <Dimension>4.27 m x 3.22 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Full bathroom</Type>
                        <Width />
                        <Length />
                        <Level>Second level</Level>
                        <Dimension>n/a</Dimension>
                    </Room>
                    <Room>
                        <Type>Recreational, Games room</Type>
                        <Width>9.59 m</Width>
                        <Length>3.64 m</Length>
                        <Level>Main level</Level>
                        <Dimension>3.64 m x 9.59 m</Dimension>
                    </Room>
                    <Room>
                        <Type>Partial bathroom</Type>
                        <Width />
                        <Length />
                        <Level>Main level</Level>
                        <Dimension>n/a</Dimension>
                    </Room>
                    <Room>
                        <Type>Laundry room</Type>
                        <Width />
                        <Length />
                        <Level>Main level</Level>
                        <Dimension>n/a</Dimension>
                    </Room>
                </Rooms>
                <SizeExterior />
                <SizeInterior>132 m2</SizeInterior>
                <StoriesTotal>1</StoriesTotal>
                <Type>House</Type>
                <Uffi>No never present</Uffi>
                <UtilityWater>Municipal water</UtilityWater>
            </Building>
            <Land>
                <SizeTotalText>35.5X55.9XIRR M (116.6X180FT)|1/2 - 1 acre</SizeTotalText>
                <SizeFrontage />
                <Acreage>false</Acreage>
                <Amenities>Golf Course, Ski area</Amenities>
                <FenceTotal />
                <LandscapeFeatures>Landscaped, Underground sprinkler</LandscapeFeatures>
                <Sewer>Septic System</Sewer>
                <SizeIrregular>35.5X55.9XIRR M (116.6X180FT)</SizeIrregular>
            </Land>
            <Address>
                <StreetAddress>70 DAVENPORT DR</StreetAddress>
                <AddressLine1>70 DAVENPORT DR</AddressLine1>
                <City>HILLSDALE</City>
                <Province>Ontario</Province>
                <PostalCode>L0L1V0</PostalCode>
                <Country>Canada</Country>
            </Address>
            <AlternateURL>
                <BrochureLink>http://peggyhill.com/listings/1306586</BrochureLink>
                <MapLink>https://maps.simcoe.ca/Advanced/RealEstate/viewer.aspx?Site=SCRealEstate&amp;ReloadKey=True&amp;MapResource=DynamicUnSecured&amp;LayerName=Property For Sale (polygon)&amp;FieldName=MLSNO&amp;FieldValues=1306586</MapLink>
                <SoundLink>http://www.youtube.com/embed/8sBzOcUcmPE?rel=0</SoundLink>
                <VideoLink>http://www.youtube.com/embed/8sBzOcUcmPE?rel=0</VideoLink>
            </AlternateURL>
            <AmmenitiesNearBy>Golf Course, Ski area</AmmenitiesNearBy>
            <Features>Treed, Wooded area</Features>
            <ParkingSpaces>
                <Parking>
                    <Name>Garage</Name>
                </Parking>
                <Parking>
                    <Name>Attached garage</Name>
                </Parking>
            </ParkingSpaces>
            <Photo>
                <PropertyPhoto>
                    <SequenceId>1</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>2</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>3</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>4</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>5</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>6</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>7</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>8</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>9</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>10</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>11</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
                <PropertyPhoto>
                    <SequenceId>12</SequenceId>
                    <LastUpdated>21/08/2013 3:43:11 PM</LastUpdated>
                </PropertyPhoto>
            </Photo>
            <Price>374900.00</Price>
            <PropertyType>Single Family</PropertyType>
            <PublicRemarks>Welcome to 70 Davenport Drive! A hidden gem in the quaint town of Hillsdale where winding tree-lined streets lead you to an impeccably cared for fully finished 2,000+ sq. foot all brick raised bungalow.  Experience the best of both worlds while living in a private setting with the luxury of commuter routes, skiing, exclusive golf, parks, schools, local shopping being minutes away.  Curb appeal plus with parking for 6 cars, paved driveway, turret style front, double wide entry and beautiful mature trees.  Inside, the large Foyer has ceramic floors, custom oak railings and staircase and leads up to the main living space.  The open concept Living Room and Dining Room have hardwood maple floors, neutral paint, palladium window, coffered ceiling with lighting, and a fabulous 3 sided Napoleon gas fireplace with water feature and custom walnut top.  A chef's delight is the Kitchen with oversized double door pantry with stainless steel shelving, maple cabinets with built in wine glass rack, 3 stainless appliances and an over range microwave and French doors.  Two Bedrooms have eco-friendly bamboo floors, neutral paint, double closets, custom blinds.  The Master Suite has a 5 piece Ensuite with glass door shower, corner Jacuzzi tub and his and hers sinks.  Rounding off this floor is the Main 4 piece Bathroom.  Downstairs is fully finished with space enough to add another Bedroom but currently has an Entertainment zone, home office &amp; fitness area, water softener &amp; UV filter. Thoughtful inclusions are laminate floors, radiant heat throughout the lower level, huge bright windows, neutral paint, 2 Piece Bathroom, inside garage entry and a walk out to the backyard haven with a 3 season gazebo.  The Laundry room has a large window and shelves.  Outside has a 'cottage retreat-like' feel with muli-level decking, a treed private yard, extensive gardens, 8 x 12 chalet style shed all set on .65 of an acre.</PublicRemarks>
            <UtilitiesAvailable>
                <Utility>
                    <Type>Natural Gas</Type>
                    <Description>Available</Description>
                </Utility>
                <Utility>
                    <Type>Water</Type>
                    <Description>Available</Description>
                </Utility>
            </UtilitiesAvailable>
            <ViewType>View</ViewType>
            <AnalyticsClick>&lt;![CDATA[&lt;script type='text/javascript'&gt;
 function redirect() {
var event = new RlEvent('crealocation');
event.viewedProperty(13560156,2100,[1460791,1452910],[272203,272203],[1587467,1587467],[0,0]);
event.set('event', 'type', 'click');
event.record();
setTimeout("window.location = 'http://peggyhill.com/listings/1306586'",500);}
&lt;/script&gt;]]&gt;</AnalyticsClick>
            <AnalyticsView>&lt;![CDATA[&lt;script src='http://analytics.crea.ca/crearl.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script type='text/javascript'&gt;
var event = new RlEvent('crealocation');
event.viewedProperty(13560156,2100,[1460791,1452910],[272203,272203],[1587467,1587467],[0,0]);
event.set('event', 'type', 'view');
event.record();
&lt;/script&gt;]]&gt;</AnalyticsView>
            <MoreInformationLink>http://peggyhill.com/listings/1306586</MoreInformationLink>
        </PropertyDetails>
    </RETS-RESPONSE>
</RETS>

Port calculation incorrect for https

When trying to connect to a secure URL, it was failing with an unhelpful "NSS error -12263" error in the debug log. After debugging, I found that the issue was that the RETSRequest() method was adding the port to the request url, but was adding the wrong port for SSL. It was adding port 80, instead of port 443.

I worked around the issue by updating my request url to include port :443, so the code wouldn't have to calculate it. However, the port calculation should be updated to take into account https vs http.

Something like:

$this->server_port = (empty($url_parts['port'])) ? (($url_parts['scheme'] == 'https') ? 443 : 80) : $url_parts['port'];

Set-Cookies compliant Methods

Does 1.0 support this? We can't use 2.0 because our servers have to run php 5.3 and can't run 5.4 without a complete rewrite our our product. Below is the info I am questioning.


now enforcing Set-Cookies compliant methods.

The Set-Cookies were appended rather than two distinct cookies in the response header. The RFC 2109 states that this Set-Cookies method is valid.

Please refer to RFC2101 Section 4.2.2: http://www.ietf.org/rfc/rfc2109.txt

This states:

Informally, the Set-Cookie response header comprises the token Set-
Cookie, followed by a comma-separated list of one or more Session-IDs.

The server is sending two cookies (Session IDs), not two cookie headers. Two cookies are sent using the current HTTP standard which requires them to be on the same line. Sending multiple headers while supported by most browsers as it was ambiguous in the first standard, it is now not the RFC-compliant method and was clarified in the refreshed HTTP cookie standard two years ago (RFC6265 Sec 4.1.1 - Pg. 9) The HTTP design is that each header should only exist once in any single request, multiple instances of a header should be an array or list of elements on the header.

Proper Response and Request:

Example:

-- RESPONSE: --
200 OK
Set-Cookie: RETS-Session-ID=97513634597; Path=/,MRIS1_RETS-Session-ID=hknhnmmiakoohcobpcebajdiapmlblngpgljpjhmkmjcpkkanahkccpccgcmplpfkaalflinaiog; Path=/
Server: nginx

-- REQUEST: --
Cookie: RETS-Session-ID=97513634597; MRIS1_RETS-Session-ID=hknhnmmiakoohcobpcebajdiapmlblngpgljpjhmkmjcpkkanahkccpccgcmplpfkaalflinaiog

Running out of memory with preg_replace()

After around a couple of hours importing listings into wp database it gets out of memory always by the same lines 246 and 248 with a preg_replace()

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 2178151 bytes) in /home/www/public_html/custom-scripts/phrets/phrets.php on line 246

PHRETS with cakephp

Client error response [url] https://rets-stage-paragon.sandicor.com/rets/fnisrets.aspx/SANDICOR/login [status code] 401 [reason phrase] Invalid Username/Password combination
when I directly call the login url from the browser, it login successfully.

Some times it shows this type Error
RETS ReplyCode="20036" ReplyText="miscellaneous server error.RETS
When url run in browser or using PHRETS plugin

Could You send any demo url means, it is very usefully to check the PHRETS plugin

Offset when set to 0

There are some MLS vendors i've worked through whom require you to set Offset=0 in order to get the first results. I noticed that on line 516 I see this:

if (!empty($optional_params['Offset'])) {
$search_arguments['Offset'] = $optional_params['Offset'];
}
elseif ($this->offset_support && empty($optional_params['Offset'])) {
// start auto-offset looping with Offset at 1
$search_arguments['Offset'] = 1;
}
else { }

However if my arguement is array('Offset'=>0); it hits the ending else clause {} when my thought is that it would be hitting !empty (as the 0 is a valid request).

To fix this; I changed line 516 to:

if (isset($optional_params['Offset']))

Thanks!

Unable to Connect To RETS

FireWall Test:
Firewall Test: google.com:80 GOOD
Firewall Test: demo.crt.realtors.org:80 FAILED
Firewall Test: demo.crt.realtors.org:6103 FAILED
Firewall Test: retsgw.flexmls.com:80 GOOD
Firewall Test: retsgw.flexmls.com:6103 GOOD
Firewall Result: At least one port 6103 test passed. Likely cause: One of the test servers might be down but connections on port 80 and port 6103 should work.

Not able to pass request to asp.net based web service

I want to fire following type of curl request, but it seems it is not passing all the required parameters and it is giving error, "Missing Parameter ID"

http://brc.rebretstest.interealty.com/GetMetadata.asmx/GetMetadata?Type=METADATA-RESOURCE&ID=0&Format=STANDARD-XML

But if i make request in the following form http://brc.rebretstest.interealty.com/GetMetadata.asmx/GetMetadata?ID=0&Type=METADATA-RESOURCE&Format=STANDARD-XML

Then it is not giving any error, but is not showing any data, since other parameters are not passed properly

Is there any specific reason that it is not working,the problem seems to be that it is not allowing me to pass multiple parameters

PHP RETS

give below search query properly work with DATE and PRICE but not working with few fields like, PROP_TYPE, CATEGORY etc.. in phrets
plz help me how to resolve this issue
$search = $rets->SearchQuery(
'Property', // Resource
'RES', // Class
'(PROP_TYPE=Single Family Detached)', //'((112=' . $sixmonths . '+),(178=ACT))', // DMQL, with SystemNames
array(
'Format' => 'COMPACT-DECODED',
'Count' => 1,
'Limit' => 20
)
);

PHRETS Error

I am getting the following errors

Warning: curl_setopt(): 700 is not a valid cURL handle resource in phrets.php on line 1561
Warning: curl_setopt(): 700 is not a valid cURL handle resource in phrets.php on line 1588
Warning: curl_setopt(): 700 is not a valid cURL handle resource in phrets.php on line 1590
Warning: curl_exec(): 700 is not a valid cURL handle resource in phrets.php on line 1592
Warning: curl_getinfo(): 700 is not a valid cURL handle resource in phrets.php on line 1593

correct username and password but Cannot login

$login = 'https://rets-stage-paragon.sandicor.com/rets/fnisrets.aspx/sandicor/login';
$un = '*******';
$pw = '**
*****';

Connect($login, $un, $pw); $rets->FirewallTest(); /_ Query Server */ if($connect) { $types = $rets->GetMetadataTypes(); print_r($types); $rets->Disconnect(); } else { $error = $rets->Error(); print_r($error); } ?>

Output:

Firewall Test: google.com:80 GOOD

Firewall Test: demo.crt.realtors.org:80 FAILED

Firewall Test: demo.crt.realtors.org:6103 FAILED

Firewall Test: retsgw.flexmls.com:80 GOOD

Firewall Test: retsgw.flexmls.com:6103 GOOD

Firewall Result: At least one port 6103 test passed. Likely cause: One of the test servers might be down but connections on port 80 and port 6103 should work.Array
(
[type] => http
[code] => 0
[text] =>
)

On Connect() when Action is provided - line 1502 Undefined index: ReplyCode

When connecting to an IDX with an Action, the ReplyCode is missing from the last_request array. The notice occurs on line 1502 when evaluating if the ReplyCode equals 0.

To fix this, change the if Action capability to the following:

    // if 'Action' capability URL is provided, we MUST request it following the successful Login
    if (isset($this->capability_url['Action']) && !empty($this->capability_url['Action'])) {
        $result = $this->RETSRequest($this->capability_url['Action']);
        if (!$result) {
            return false;
        }

        // parse action body response
        $xml = $this->ParseXMLResponse($body);
        if (!$xml) {
            return false;
        }

        // log replycode and replytext for reference later
        $this->last_request['ReplyCode'] = "{$xml['ReplyCode']}";
        $this->last_request['ReplyText'] = "{$xml['ReplyText']}";

        list($headers,$body) = $result;
    }

Servers with no offset support

Troy,
can you create a full example for servers , like interealty, that have no offset support.and then another one with rets saving to mysql
thanks

Possible improvement: add ability to add arbitrary cURL options

I thought of a significantly better way to deal with #33 (sorry I should have created an issue before I sent a pull request)... I'll change the pull request and re-open it if you like this idea:

Could we make $ch protected so we can override RETSQuery and access $ch directly via a subclass?

Conection issue on live server

When I used to connect phrets on my local server it works perfectly.
But when I used it to connect on Live server the connection is not established.

In debug file I got msg:-

  • About to connect() to rets.torontomls.net port 6103 (#0)
  • Trying 68.71.195.47... * Connection timed out
  • couldn't connect to host
  • Closing connection #0

//Code is as follows:-

$rets = new phRETS;
$rets->AddHeader("RETS-Version", "RETS/1.5");
$rets->SetParam("debug_mode", true);
$rets->SetParam("disable_follow_location", true);
echo "+ Connecting to {$rets_login_url} as {$rets_username}
\n";
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password);
if ($connect) {
echo " + Connected
\n";
}
else {
echo " + Not connected:
\n";
print_r($rets->Error());
exit;
}

Please help me.. what are the possibilities may occer..

Photo URL retrieval issue

Hello, I am having a problem in downloading Photos URL, I looked up for the available fields in retsmd.com but didn't find 'Photo Location' Field. but when i try to download the data from RETS Connector it shows me the exact field having all the photo URLs. Moreover, I tried to download the photos using GetObject Method but i dont see Location field there too.

P.S i am connecting to SANDICOR, Inc. in San Diego.

$search_data isn't declared in the PHRETS class

$search_data isn't declared in the PHRETS class (other than implicitly by PHP)

The problem is that if in a child class a getter function is used (and isn't returning a reference), this causes search_data to always be empty.

However, even if said getter is returning a reference, should $search_data not be private?

phrets 2.x composer install issue

might want to update the install instructions for the 2.x branch. The posted require line results in an error:

Your requirements could not be resolved to an installable set of packages.

The require line should be

{ "require": { "troydavisson/phrets": "2.*@dev" } }

Optional Parameter Count=0 is treated as 1

I've been having problems with telling the server to not return a count of the number of matching records. If I supply Count as an optional parameter to $phRETS->SearchQuery() with a value of 0, I always get Count = 1 in the final query formed. This is due to 0 being evaluated as true when checked by empty()

In the PHP class, find:

$search_arguments['Count'] = empty($optional_params['Count']) ? 1 : $optional_params['Count'];

Instead, it should check for null. Replacing it with:

$search_arguments['Count'] = $optional_params['Count'] === NULL ? 1 : $optional_params['Count'];

This corrected the behavior and allowed me to supply it as 0 to not return a count of listings which matched my criteria. Very useful if you're getting all of the records as it greatly reduces the load on the server.

PHRETS 2.0 and not keep auth stored

Hey Troy,

First, thanks for the awesome phRets software. It is awesome. I noticed that you working on 2.0 branch and I was testing it. I just tried your example code with real rets server information and I get the follow error. It seems like it is not keep auth from the connect line (this is on the $rets->GetSystemMetadata(); line).

**Fatal error**:  Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] http://example.com/rets/getmetadata?Type=METADATA-SYSTEM&amp;ID=0&amp;Format=STANDARD-XML [status code] 401 [reason phrase] Unauthorized' in /home/example/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:68
Stack trace:
#0 /home/example/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(31): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response))
#1 /home/example/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(105): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete')
#2 /home/example/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php(75): GuzzleHttp\Event\Emitter->emit('complete', Object(GuzzleHttp\Event\CompleteEvent))
#3 /home/example/idx.ii in **/home/example/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php** on line **68**

Any idea what might be going on?

GetObject: minor inconsistency

There is a minor issue (inconsistency) in GetObject() related to how it treats $this->last_request.

If the GetObject() response is not multi-part -- and the response is a RETS error then $this->last_request is populated with the reply code and the reply text (lines 388-399):

$this->last_request['ReplyCode'] = "{$xml['ReplyCode']}";
$this->last_request['ReplyText'] = "{$xml['ReplyText']}";

This could be handy as one can quickly check (without inspecting individual images in the returned array) the reply code through a call to LastRequest() to see if there was an error.

The inconsistent part is that this is the only spot in GetObject() where $this->last_request is populated.

So, if we have a sequence of GetObject() calls -- and somewhere in the sequence an error occurs.. $this->last_request['ReplyCode'] and $this->last_request['ReplyText'] "carry over" for each additional request.

This makes the method LastRequest() not true to its name -- since its return data would be related to the GetObject() request that failed last -- and not the last request.

"Solution": either always populate $this->last_request when GetObject() is called.. or never populate it.

In the former -- we simply need to "clear" $this->last_request['ReplyCode'] (set it to 0 if we get a valid response) and $this->last_request['ReplyText'] (set it to the empty string) whenever we get a valid response (multiple images or an individual one).

In the later -- we simply need to remove the bit where it's populated (lines 388-399) -- and probably be explicit in the documentation that LastRequest() will not return any information for the last GetObject() call.

Thoughts?

Query Error - New to PHPRETS

I am new to PHPRETS. I have been able to make a connection. I am just starting to try and get a handle on this info. I tried using various SearchQuery -> examples even those provided on here but I keep getting this error. I can't figure out why.

Array ( [type] => rets [code] => 20203 [text] => Invalid Query Type. )

Here is my basic code...

$rets_login_url = "_";
$rets_username = "_
_";
$rets_password = "
_*****";

require_once("phrets.php");

$rets = new phRETS;

$rets->AddHeader('Accept', "* / *");
$rets->AddHeader('RETS-Version',"RETS/1.7");
$rets->SetParam("debug_mode", true);

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

if ($connect)
{
echo " + Connected
\n";
} else {
echo " + Not connected:
\n";
print_r($rets->Error());
exit;
}

$search = $rets->SearchQuery("Property","RES,"(CIT=FRANKFORT)");

print_r($rets->Error());

I tried using listed names on examples sites like this one and looked up the names with my MLS info. No matter what I put in there it gives me that error.

Thanks

Board changed RETS servers, lost on how to proceed

The realtor board that a friend works under changed from a ProMatch server running 1.7.2 to an Innovia Server running 1.5. When I changed over the credentials, I am having some issues getting things to work. For instance, in this case, I am trying to create tables on the database that match the same fields as the class tables on the RETS server. Can someone explain why this was able to work on the old server but not on the new one? I've been banging my head against the wall and could really use some guidance.

255) { $sql_make .= "TEXT"; } elseif ($field['DataType'] == "Decimal") { $pre_point = ($field['MaximumLength'] - $field['Precision']); $post_point = !empty($field['Precision']) ? $field['Precision'] : 0; $sql_make .= "DECIMAL({$field['MaximumLength']},{$post_point})"; } elseif ($field['DataType'] == "Boolean") { $sql_make .= "CHAR(1)"; } elseif ($field['DataType'] == "Date") { $sql_make .= "DATE default '0000-00-00' not null"; } elseif ($field['DataType'] == "Time") { $sql_make .= "TIME default '00:00:00' not null"; } else { $sql_make .= "VARCHAR(255)"; } $sql_make .= " COMMENT '{$cleaned_comment}'"; $sql_make .= ",\n"; $sql_query .= $sql_make; } $sql_query .= "PRIMARY KEY(`{$field_prefix}{$key_field}`) )"; return $sql_query; ``` } // dependencies require('../../../include/config-cr.php'); mysql_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); $rets_login_url = "http://rets.offutt-innovia.com:8080/der/login"; $rets_username = "**_"; $rets_password = "**_"; require_once("phrets.php"); // start rets connection $rets = new phRETS; // only enable this if you know the server supports the optional RETS feature called 'Offset' $rets->SetParam("offset_support", true); echo "+ Connecting to {$rets_login_url} as {$rets_username}
\n"; $connect = $rets->Connect($rets_login_url, $rets_username, $rets_password); if ($connect) { echo " + Connected
\n"; } else { echo " + Not connected:
\n"; print_r($rets->Error()); exit; } // gets resource information. need this for the KeyField $rets_resource_info = $rets->GetMetadataInfo(); $resource = "Property"; $classes = $rets->GetMetadataClasses("Property"); foreach ($classes as $class) { ``` // pull field format information for this class $rets_metadata = $rets->GetMetadata($resource, $class['ClassName']); $table_name = "clrcr_rets2_".strtolower($class['ClassName']); $sql = create_table_sql_from_metadata($table_name, $rets_metadata, $rets_resource_info[$resource]['KeyField']); mysql_query($sql); ``` } echo "+ Disconnecting
\n"; $rets->Disconnect(); ?>

Get setup PHRETS

I am using FLEXMLS RETS and When I click activate, it takes me to your page. Please help

Unable to login, Cookie issue?

I am having trouble login in to a rets server and i think is something related to cookies. If i use curl command line using a cookie jar file it works (Important: if i dont use a cookie file its not working)

Here is the debug log from the phrets.

[2015-04-29 02:43:23] PHRETS.DEBUG: Loading Monolog\Logger logger [] []
[2015-04-29 02:43:23] PHRETS.DEBUG: Sending HTTP Request for https://rets.crmls.org/contact/rets/login (Login) {"cookies":true,"debug":true} []

  • About to connect() to rets.crmls.org port 443 (#0)
  • Trying 209.80.40.144...
  • Connected to rets.crmls.org (209.80.40.144) port 443 (#0)
  • successfully set certificate verify locations:
  • CAfile: /home/radu/zsuite-dev/vendor/guzzlehttp/guzzle/src/cacert.pem
    CApath: none
  • SSL connection using RC4-MD5
  • Server certificate:
  •    subject: C=US; ST=California; L=San Dimas; O=California Regional Multiple Listing Service, Inc; CN=rets.crmls.org
    
  •    start date: 2015-04-03 21:14:07 GMT
    
  •    expire date: 2017-04-04 12:52:25 GMT
    
  •    subjectAltName: rets.crmls.org matched
    
  •    issuer: C=US; O=Entrust, Inc.; OU=See www.entrust.net/legal-terms; OU=(c) 2012 Entrust, Inc. - for authorized use only; CN=Entrust Certification Authority - L1K
    
  •    SSL certificate verify ok.
    
  • Server auth using Digest with user 'USER'

    GET /contact/rets/login HTTP/1.1
    Accept-Encoding: gzip
    Host: rets.crmls.org
    RETS-Version: RETS/1.7.2

< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=37C5D5128B409C50F0512630F5576E38; Path=/contact
< Set-Cookie: JSESSIONID=37C5D5128B409C50F0512630F5576E38; Path=/contact
< MIME-Version: 1.0
< Cache-Control: private
< RETS-Version: RETS/1.7.2
< WWW-Authenticate: Digest realm="[email protected]",qop="auth",nonce="a046d8c8edf907fac4c9075805c9d039", opaque="9885bba5142ce"
< Content-Type: text/html;charset=utf-8
< Content-Length: 954
< Date: Wed, 29 Apr 2015 09:43:22 GMT
<

  • Ignoring the response-body
  • Connection #0 to host rets.crmls.org left intact
  • Issue another request to this URL: 'https://rets.crmls.org/contact/rets/login'
  • Found bundle for host rets.crmls.org: 0x1aa411d0
  • Re-using existing connection! (#0) with host rets.crmls.org
  • Connected to rets.crmls.org (209.80.40.144) port 443 (#0)
  • Server auth using Digest with user 'USER'

    GET /contact/rets/login HTTP/1.1
    Authorization: Digest username="USER", realm="[email protected]", nonce="a046d8c8edf907fac4c9075805c9d039", uri="/contact/rets/login", cnonce="ICAgICAgICAgICAgICAgICAgICAgICAgMzc4OTY0MzQ=", nc=00000001, qop=auth, response="ae40d6c00dfb2779b84325a974eb8ba4", opaque="9885bba5142ce"
    Accept-Encoding: gzip
    Host: rets.crmls.org
    RETS-Version: RETS/1.7.2

< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=1CAB2481E7B7DCD20C72E5F3CE4380F9; Path=/contact
< Set-Cookie: JSESSIONID=1CAB2481E7B7DCD20C72E5F3CE4380F9; Path=/contact
< MIME-Version: 1.0
< Cache-Control: private
< RETS-Version: RETS/1.7.2

  • Authentication problem. Ignoring this.
    < WWW-Authenticate: Digest realm="[email protected]",qop="auth",nonce="243f4e6d676cdc7b5367a41f2b080102", opaque="da1d19d00e2c4"
    < Content-Type: text/html;charset=utf-8
    < Content-Length: 954
    < Date: Wed, 29 Apr 2015 09:43:23 GMT
    <
  • Connection #0 to host rets.crmls.org left intact
    PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] https://rets.crmls.org/contact/rets/login [status code] 401 [reason phrase] Unauthorized' in /home/radu/zsuite-dev/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:68

This is the request using curl command line and a cookie jar file.

  • About to connect() to rets.crmls.org port 443 (#0)
  • Trying 209.80.40.144...
  • Connected to rets.crmls.org (209.80.40.144) port 443 (#0)
  • successfully set certificate verify locations:
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • SSLv3, TLS handshake, Client hello (1):
  • SSLv3, TLS handshake, Server hello (2):
  • SSLv3, TLS handshake, CERT (11):
  • SSLv3, TLS handshake, Server finished (14):
  • SSLv3, TLS handshake, Client key exchange (16):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSLv3, TLS change cipher, Client hello (1):
  • SSLv3, TLS handshake, Finished (20):
  • SSL connection using RC4-MD5
  • Server certificate:
  •    subject: C=US; ST=California; L=San Dimas; O=California Regional Multiple Listing Service, Inc; CN=rets.crmls.org
    
  •    start date: 2015-04-03 21:14:07 GMT
    
  •    expire date: 2017-04-04 12:52:25 GMT
    
  •    subjectAltName: rets.crmls.org matched
    
  •    issuer: C=US; O=Entrust, Inc.; OU=See www.entrust.net/legal-terms; OU=(c) 2012 Entrust, Inc. - for authorized use only; CN=Entrust Certification Authority - L1K
    
  •    SSL certificate verify ok.
    
  • Server auth using Digest with user 'USER'

    GET /contact/rets/login HTTP/1.1
    User-Agent: curl/7.29.0
    Host: rets.crmls.org
    Accept: /

    < HTTP/1.1 401 Unauthorized
    < Server: Apache-Coyote/1.1
  • Added cookie JSESSIONID="13DDA9E8A272F02041C23DA2CB14CF66" for domain rets.crmls.org, path /contact, expire 0
    < Set-Cookie: JSESSIONID=13DDA9E8A272F02041C23DA2CB14CF66; Path=/contact
  • Replaced cookie JSESSIONID="13DDA9E8A272F02041C23DA2CB14CF66" for domain rets.crmls.org, path /contact, expire 0
    < Set-Cookie: JSESSIONID=13DDA9E8A272F02041C23DA2CB14CF66; Path=/contact
    < MIME-Version: 1.0
    < Cache-Control: private
    < RETS-Version: RETS/1.7.2
    < WWW-Authenticate: Digest realm="[email protected]",qop="auth",nonce="eece9c0ac2820413b7d80e47a1f4789a", opaque="2a7dd40718d3f"
    < Content-Type: text/html;charset=utf-8
    < Content-Length: 954
    < Date: Wed, 29 Apr 2015 09:50:20 GMT
    <
  • Ignoring the response-body
  • Connection #0 to host rets.crmls.org left intact
  • Issue another request to this URL: 'https://rets.crmls.org/contact/rets/login'
  • Found bundle for host rets.crmls.org: 0x4c92b60
  • Re-using existing connection! (#0) with host rets.crmls.org
  • Connected to rets.crmls.org (209.80.40.144) port 443 (#0)
  • Server auth using Digest with user 'USER'

    GET /contact/rets/login HTTP/1.1
    Authorization: Digest username="USER", realm="[email protected]", nonce="eece9c0ac2820413b7d80e47a1f4789a", uri="/contact/rets/login", cnonce="ICAgICAgICAgICAgICAgICAgICAgICAgMzczNTIzODc=", nc=00000001, qop=auth, response="cd4d49644270dccffec3279472b017a0", opaque="2a7dd40718d3f"
    User-Agent: curl/7.29.0
    Host: rets.crmls.org
    Accept: /
    Cookie: JSESSIONID=13DDA9E8A272F02041C23DA2CB14CF66

    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
  • Replaced cookie JSESSIONID="13DDA9E8A272F02041C23DA2CB14CF66" for domain rets.crmls.org, path /contact, expire 0
    < Set-Cookie: JSESSIONID=13DDA9E8A272F02041C23DA2CB14CF66; Path=/contact
    < MIME-Version: 1.0
    < Cache-Control: private
    < RETS-Version: RETS/1.7.2
    < WWW-Authenticate: Digest realm="[email protected]",qop="auth",nonce="5dabdbe626af5b6bda7ec08ef333a2f7", opaque="08346b25456d0"
  • Added cookie RETS-Session-ID="bff2c4d1714c79cf94c50e215c159d9214d049593af" for domain rets.crmls.org, path /contact, expire 0
    < Set-Cookie: RETS-Session-ID=bff2c4d1714c79cf94c50e215c159d9214d049593af; Path=/contact
    < Content-Type: text/xml
    < Content-Length: 595
    < Date: Wed, 29 Apr 2015 09:50:21 GMT
    <


    MemberName=User Inc.
    User=User ,0,IDXFeed,User
    Broker=
    MetadataVersion=1.00.00014
    MetadataTimestamp=2015-04-06T16:06:51
    MinMetadataTimestamp=2015-04-06T16:06:51
    TimeoutSeconds=1800000
    Action=/contact/rets/action
    GetMetadata=/contact/rets/getMetadata
    GetObject=/contact/rets/getObject
    Login=/contact/rets/login
    Logout=/contact/rets/logout
    X-PostObject=/contact/rets/postObject
    Search=/contact/rets/search
    X-Selector=/contact/rets/selector
    Update=/contact/rets/update

  • Connection #0 to host rets.crmls.org left intact

First request

GET /contact/rets/login HTTP/1.1
Authorization: Digest username="USER", realm="[email protected]", nonce="a046d8c8edf907fac4c9075805c9d039", uri="/contact/rets/login", cnonce="ICAgICAgICAgICAgICAgICAgICAgICAgMzc4OTY0MzQ=", nc=00000001, qop=auth, response="ae40d6c00dfb2779b84325a974eb8ba4", opaque="9885bba5142ce"
Accept-Encoding: gzip
Host: rets.crmls.org
RETS-Version: RETS/1.7.2

Second request

Authorization: Digest username="USER", realm="[email protected]", nonce="eece9c0ac2820413b7d80e47a1f4789a", uri="/contact/rets/login", cnonce="ICAgICAgICAgICAgICAgICAgICAgICAgMzczNTIzODc=", nc=00000001, qop=auth, response="cd4d49644270dccffec3279472b017a0", opaque="2a7dd40718d3f"
User-Agent: curl/7.29.0
Host: rets.crmls.org
Accept: /
Cookie: JSESSIONID=13DDA9E8A272F02041C23DA2CB14CF66

So you can actually see that the first request is missing the cookie resulting in a 401 error.

About receiving response 20207 from RETS server

response_recieved_from_rets_server_after_sending_request
Hello Team,
Greetings!!

We are accesing RETS server using Bluehost account IP details but not getting proper response. We are getting error like below in red colored text.

20207=Unauthorized Query:The query could not be executed because it refers to a field to which the supplied login does not grant access.

Can you please look at this. And provide me helpful solution.

Please find required details below along with attachments.(I have attached used script to connect & retrieve data from RETS)

There are three attached files.

  1. Class file called 'phrets.php' which is included in another file called 'rets_search.php'

We have written script along with Blue host Server login credentials(Because RETS allows access using only Blue host Account IP) to connect with RETS server & retrieve data from RETS server in second file. i.e 'rets_search.php'

You can send them those attached source code files.

And there is another attached files called 'Response_recieved_from_RETS_Server_after_sending_request.jpg' which includes received response from RETS server.
Also you can cross check received response at http://yatesdevelopment.com/RETS_CSV/rets_search.php

response_recieved_from_rets_server_after_sending_request

Connecting to RETS 1.7

I'm having trouble using the example Download CSV script on a 1.7 server. It connects but finds 0 records no matter what the date is

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.