Unable to login with PHRETS (401), other methods work.

763 views
Skip to first unread message

wbo...@gmail.com

unread,
Dec 4, 2008, 3:34:22 PM12/4/08
to PHRETS
I'm attempting to do a simple login/logout to the mfr.mlxchange.com
website using PHRETS. The test system is Windows XP Pro running PHP
5.2.5. Here is the sample .php file that does the connecting to the
server:

<?php
require "phrets.php";

$rets = new phRETS;

$rets->AddHeader("Accept", "*/*");
$rets->AddHeader("RETS-Version", "RETS/1.5");
$rets->AddHeader("User-Agent", "MS/1.5");
$rets->SetParam("cookie_file", "phrets_cookies.txt");
$rets->SetParam("debug_mode", TRUE);

$rets->Connect("http://mfr.rets.interealty.com/Login.asmx/Login",
"<user id>",
"<password>");

echo "Server reports: " . $rets->GetServerVersion()."\n";
?>

When I call this file from the command line, I get the following
response:

* About to connect() to mfr.rets.interealty.com port 80 (#0)
* Trying 12.32.9.169... * connected
* Connected to mfr.rets.interealty.com (12.32.9.169) port 80 (#0)
> GET /Login.asmx/Login HTTP/1.1
Host: mfr.rets.interealty.com
Accept-Encoding: gzip
Accept: */*
RETS-Version: RETS/1.5
User-Agent: MS/1.5


< HTTP/1.1 401 Unauthorized
< Connection: close
< Date: Thu, 04 Dec 2008 20:23:12 GMT
< Server: Microsoft-IIS/6.0
< Cache-Control:private
< X-AspNet-Version: 2.0.50727
< WWW-Authenticate: Basic realm="re...@mfr.rets.interealty.com"
< WWW-Authenticate: Digest
realm="re...@mfr.rets.interealty.com",nonce="91310a7a44379fdcdd63a3b2f604d7f9",opaque="072ef9cf-
db0d-45d7-a3ab-33ce7438545c",qop="auth"
< Cache-Control: private
< Content-Type: text/plain
* Issue another request to this URL: 'http://mfr.rets.interealty.com:
80/Login.asmx/Login'
* Examining connection #0 for reuse
* Re-using existing connection! (#0) with host mfr.rets.interealty.com
* Connected to mfr.rets.interealty.com (12.32.9.169) port 80 (#0)
* Server auth using Digest with user '<user id>'
> GET /Login.asmx/Login HTTP/1.1
Authorization: Digest username="<user id>",
realm="re...@mfr.rets.interealty.com",
nonce="91310a7a44379fdcdd63a3b2f604d7f9", uri="/Login.asmx/Login",
cnonce="MDAxMzE5", nc=00000001, qop="auth",
response="98fb71f966f23b2a0a328990cd5ac656", opaque="072ef9cf-
db0d-45d7-a3ab-33ce7438545c"
Host: mfr.rets.interealty.com
Accept-Encoding: gzip
Accept: */*
RETS-Version: RETS/1.5
User-Agent: MS/1.5


* Connection #0 to host mfr.rets.interealty.com left intact
* Closing connection #0



The reason I am posting this is because I can use the same credentials
when attempting to login through a VB.Net program using the
librets.dll file so I know that the URL, user name and password are
correct. Can anyone point me in the right direction as to what I
might look at to get this working?

Troy Davisson

unread,
Dec 4, 2008, 7:15:49 PM12/4/08
to phr...@googlegroups.com
The bottom of the log is suggesting that there's a connection timeout
unless the response has been chopped off prior to posting. Is this
consistent with how it's acting?

The 401 response following the initial GET is natural and required in
digest authentication. This gives the server the first opportunity to
send back it's digest values which the client needs to calculate the
password to pass back in the 2nd GET. The next response should either
be a 401 or 200 response.

Warren Bowley

unread,
Dec 4, 2008, 9:18:44 PM12/4/08
to phr...@googlegroups.com
I double-checked the log file and confirmed that what I've posted is
the last line in the file. Not knowing what to expect as correct
output I omitted what I'm seeing from the command line. The file
containing the code is called test.php and I'm doing a c:> php
test.php to execute it as you would expect. I assume that when a
non-200 response code is received, I should be seeing:

PHP Fatal error:

followed by the response body from RETS server in HTML format, but it
does not appear to be completed. It gets chopped off half way through
the RETS error page. The HTML that I can see does look like a typical
.NET error page <h1>Server error in '/' application...

followed by the error line number (769 in phrets.php).

From the log files it does appear as though the process is:

1) send initial request
2) receive 401

< HTTP/1.1 401 Unauthorized
< Connection: close

3) attempt 2nd request
4) nothing...

* Connection #0 to host mfr.rets.interealty.com left intact
* Closing connection #0

Any other ideas?

Warren Bowley

unread,
Dec 5, 2008, 8:46:00 AM12/5/08
to phr...@googlegroups.com
I decided to try a fresh install of PHP/Apache on another PC running
through a different network and the same version of code succeeded in
connecting to the server without issue. I believe my problems are a
configuration issue on the original PC. I am going to try to
download/re-install the latest version of PHP on that PC and see if it
makes a difference.

Thanks for your help.

On Thu, Dec 4, 2008 at 9:18 PM, Warren Bowley <wbo...@gmail.com> wrote:

>
> Any other ideas?
>

Warren Bowley

unread,
Dec 9, 2008, 1:03:01 PM12/9/08
to phr...@googlegroups.com
Well, I thought I could get connected with this other machine, but
unfortunately it no longer works. I'm still getting 401 errors using
the PHP code, but I can get connected with the same user information
using .Net code.

Here's the contents of rets_debug.txt

* About to connect() to mfr.rets.interealty.com port 80 (#0)
* Trying 12.32.9.169... * connected
* Connected to mfr.rets.interealty.com (12.32.9.169) port 80 (#0)
> GET /Login.asmx/Login HTTP/1.1
Host: mfr.rets.interealty.com

Accept: */*
RETS-Version: RETS/1.5
User-Agent: PHRETS/1.0


< HTTP/1.1 401 Unauthorized
< Connection: close

< Date: Tue, 09 Dec 2008 18:01:37 GMT


< Server: Microsoft-IIS/6.0
< Cache-Control:private
< X-AspNet-Version: 2.0.50727
< WWW-Authenticate: Basic realm="re...@mfr.rets.interealty.com"
< WWW-Authenticate: Digest

realm="re...@mfr.rets.interealty.com",nonce="b48963b3e850f7dd2e4a92ea0e60d527",opaque="87905771-e7ea-4e5a-9ebb-3d7af6f61a58",qop="auth"


< Cache-Control: private
< Content-Type: text/plain
* Issue another request to this URL:
'http://mfr.rets.interealty.com:80/Login.asmx/Login'
* Examining connection #0 for reuse
* Re-using existing connection! (#0) with host mfr.rets.interealty.com
* Connected to mfr.rets.interealty.com (12.32.9.169) port 80 (#0)
* Server auth using Digest with user '<user id>'
> GET /Login.asmx/Login HTTP/1.1
Authorization: Digest username="<user id>",
realm="re...@mfr.rets.interealty.com",

nonce="b48963b3e850f7dd2e4a92ea0e60d527", uri="/Login.asmx/Login",
cnonce="MDE4NDYz", nc=00000001, qop="auth",
response="e03c7dd6f93c93ab460abe41dce7500f",
opaque="87905771-e7ea-4e5a-9ebb-3d7af6f61a58"
Host: mfr.rets.interealty.com
Accept: */*
RETS-Version: RETS/1.5
User-Agent: PHRETS/1.0

Warren Bowley

unread,
Dec 9, 2008, 10:47:51 PM12/9/08
to phr...@googlegroups.com
I've been communicating with Troy off list to try and figure out the
problem. He suggested:

In the PHRETS code, find the following line:

curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);

and change it to:

curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

This has resolved my problem and it is running now. Thank you Troy.

Reply all
Reply to author
Forward
0 new messages