A simple, free, open source PHP library for using RETS.
PHP + RETS = PHRETS
PHRETS provides PHP developers a way to integrate RETS functionality directly within new or existing code. A standard class of functions is made available to developers to connect and interact with a server much like they would with other APIs.
PHRETS handles the following aspects of RETS communication for you:
- Response parsing (for other non-XML responses such as HTTP multipart)
- XML Parsing
- Simple variables and arrays returned to the developer
- RETS communication (over HTTP)
- HTTP Header management
- Authentication
- Session/Cookie management
The source code for PHRETS is available on GitHub
PHRETS is maintained in a public Git repository on GitHub. Issue submissions and pull requests are encouraged if you run into issues or if you have fixes or changes to contribute.
AddHeader ( string $name, string $value )
$name
- Header name to be passed.
$value
- Header value to be passed.
Since the header is maintained in a local settings array, this always returns boolean TRUE
1.0 - If RETS-Version isn't specifically set, it now defaults to RETS/1.5. If User-Agent isn't specifically set, it now defaults to PHRETS/1.0. If Accept isn't specifically set, it now defaults to /. This makes calling AddHeader() optional prior to connecting
Add a custom User-Agent (needed when using User-Agent Authentication):
<?php
$rets->AddHeader("User-Agent", "CustomApp/1.0");
SetParam ( string $name, string $value )
$name
and $value
represent setting pairs as described below:
- cookie_file - Path to file to use for temporary session information storage. Default is system temporary file
- debug_mode - Sets cURL output to verbose if True. Default is False.
- debug_file - Sets cURL output file. Default is rets_debug.txt in local folder.
- compression_enabled - Enables GZIP compression if True. Default is False.
- force_ua_authentication - Forces UA authentication when True. Default is False.
- disable_follow_location - In case of PHP safe_mode errors, set to True. Default is False.
- force_basic_authentication - Forces HTTP Basic authentication when True for buggy IIS servers. Default is False.
- use_interealty_ua_auth - Forces use of a different calculation for UA-Auth. Default is False.
- disable_encoding_fix - Disables automatic XML encoding fix if true
- catch_last_response - Enables GetLastServerResponse(). Default is False.
- offset_support - Turns on auto-'Offset' feature. Default is False
- override_offset_protection - Disables infinite loop protection of auto-'Offset' feature if true. Default is False.
Returns TRUE if passed parameter was valid. Returns FALSE otherwise.
1.0rc2 - Added new parameters override_offset_protection
, offset_support
, catch_last_response
and disable_encoding_fix
1.0 - Added new parameters debug_file
, force_basic_authentication
and use_interealty_ua_auth
<?php
$rets->SetParam("debug_mode", true);
$rets->SetParam("debug_file", "debug_log.txt");
<?php
$rets->SetParam("compression_enabled", true);
<?php
$rets->SetParam("disable_follow_location", true);
Connect ( string $login_url, string $username, string $password [, string $ua_pwd ] )
$login_url
- Full Login URL to the RETS server
$username
- Login username
$password
- Login password
$ua_pwd
- Optional. User-Agent Password. Default is blank. If not blank, User-Agent Authentication is forced.
If any part of the initial connection failed, returns FALSE (check Error for details). Otherwise, returns TRUE
1.0 - Dropped AddHeader requirements
Connects
<?php
$connect = $rets->Connect("http://retsserver:6103/rets/login", "Joe", "Schmoe");
if (!$connect) {
print_r($rets->Error());
}
Connects with User-Agent Authentication
<?php
$connect = $rets->Connect("http://retsserver:6103/rets/login", "Joe", "Schmoe", "ua-password");