troydavisson / PHRETS

PHP client library for interacting with a RETS server to pull real estate listings, photos and other data made available from an MLS system
http://troda.com
MIT License
451 stars 236 forks source link

Stop to LOGIN after move on new version #74

Closed masha-andreeva closed 9 years ago

masha-andreeva commented 9 years ago

Hi, I have YII1 application where i used an old version of PHRETS. My RETS provider URL is https://rets.crmls.org/contact/rets/login But they changed API (They are using RETS 1.8 specification) and there was a need to upgrade version. After upgrading PHRETS i stop to Login. Each time return:

Client error response [url] https://rets.crmls.org/contact/rets/login [status code] 401 [reason phrase] Unauthorized

Part of source: $config = new \PHRETS\Configuration; $config->setLoginUrl($loginUrl) ->setUsername($userName) ->setPassword($password) ; $rets = new \PHRETS\Session($config); $connect = $rets->Login();

troydavisson commented 9 years ago

When setting up $config, throw in a:

->setHttpAuthenticationMethod(\PHRETS\Configuration::AUTH_BASIC)

and see if that fixes it.

With version 1, did you have to specifically set any user-agent headers?

troydavisson commented 9 years ago

You may also need to:

->setRetsVersion(1.8)
masha-andreeva commented 9 years ago

troydavisson: With version 1, did you have to specifically set any user-agent headers? No

masha-andreeva commented 9 years ago

Unfortunately this ->setHttpAuthenticationMethod(\PHRETS\Configuration::AUTH_BASIC) ->setRetsVersion(1.8) doesn't help

mikebronner commented 9 years ago

Having the same issue. @masha-andreeva have you been able to resolve this? The same connection information entered in retsmd.com seems to work without issue, so there seems to be a difference in how the connection is set up.

masha-andreeva commented 9 years ago

No yet. I am thinking to try use an another library to check where is an issue.

masha-andreeva commented 9 years ago

I fixed it by adding cookie before curl invoking

$tmpfname = tempnam('/tmp', 'file-cookies'); curl_setopt($handle, CURLOPT_COOKIEJAR, $tmpfname); curl_setopt($handle, CURLOPT_COOKIEFILE, $tmpfname);