Search code examples
phpretsphretsmls

How to download STANDARD-XML metadata from RETS using PHRETS


Is there any solution to download STANDARD-XML metadata from RETS using PHRETS?

Currently am able to extract each class metadata as an array using PHRETS function GetMetadataTable and combining & converting to XML format.

But then recently I found difference in single STANDARD-XML metadata(of entire resources and classes) and individual class metadata. Using metadata viewer service RETSMD.com(built on PHRETS) also, the class name getting from STANDARD-XML metadata is different and unable to view the details.

Note: I got the STANDARD-XML metadata via direct browser log-in using credentials, like this http://rets.login.url/GetMetadata?Type=METADATA-TABLE&Format=STANDARD-XML&ID=0

Anyone faced the same? Is there any solution using PHP?

Thanks in Advance!


Solution

  • I got a solution by modifying PHRETS library. Added a new function there with following code,

        if (empty($this->capability_url['GetMetadata'])) {
            die("GetServerInformation() called but unable to find GetMetadata location. Failed login?\n");
        }
    
        $optional_params['Type']   = 'METADATA-SYSTEM';
        $optional_params['ID']     = '*';
        $optional_params['Format'] = 'STANDARD-XML';
    
        //request server information
        $result = $this->RETSRequest($this->capability_url['GetMetadata'], $optional_params );
    
        if (!$result) {
            return false;
        }
        list($headers, $body) = $result;
        $xml = $this->ParseXMLResponse($body);
    

    Note: Main thing to note is,

    $optional_params['ID']     = '*';
    

    Should be '*' instead '0'