[英]PHP - Cant connect to RETS via PHRETS
I am trying to get all my MLS listing via PHP using PHRETS which I downloaded from here: 我正在尝试使用从这里下载的PHRETS通过PHP获取我所有的MLS清单:
https://github.com/dangodev/PHRETS-Example/blob/master/lib/phrets.php https://github.com/dangodev/PHRETS-Example/blob/master/lib/phrets.php
and I used this example to download my listings into a csv format: 并且我使用以下示例将清单下载为csv格式:
https://github.com/troydavisson/PHRETS/wiki/Connect,%20download%20listing%20data%20in%20CSV%20format,%20disconnect https://github.com/troydavisson/PHRETS/wiki/Connect,%20download%20listing%20data%20in%20CSV%20format,%20disconnect
I got the RETS URL, username and password from my MLS board, but I still can't connect. 我从MLS板上获得了RETS URL,用户名和密码,但仍然无法连接。
My code returns false when call the PHRETS library here: 在此处调用PHRETS库时,我的代码返回false:
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;
}
When I goto to library and look at the method Connect, that code returns false here: 当我转到库并查看方法Connect时,该代码在此处返回false:
// make request to Login transaction
$result = $this->RETSRequest($this->capability_url['Login']);
if (!$result) {
return false;
}
And when I look at my RETSRequest Method, it returns false here because the response code is 0 and not 200 当我查看我的RETSRequest方法时,它在此处返回false,因为响应代码为0而不是200
if ($response_code != 200) {
$this->set_error_info("http", $response_code, $response_body);
return false;
}
and here is where its trying to connect: 这是它尝试连接的地方:
if ($this->ua_auth == true) {
$session_id_to_calculate_with = "";
// calculate RETS-UA-Authorization header
$ua_a1 = md5($this->static_headers['User-Agent'] .':'. $this->ua_pwd);
$session_id_to_calculate_with = ($this->use_interealty_ua_auth == true) ? "" : $this->session_id;
$ua_dig_resp = md5(trim($ua_a1) .':'. trim($this->request_id) .':'. trim($session_id_to_calculate_with) .':'. trim($this->static_headers['RETS-Version']));
$request_headers .= "RETS-UA-Authorization: Digest {$ua_dig_resp}\r\n";
}
$this->last_request_url = $request_url;
curl_setopt($this->ch, CURLOPT_URL, $request_url);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array(trim($request_headers)));
// do it
$response_body = curl_exec($this->ch);
$response_code = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
Why can't I connect? 为什么我不能连接?
I was able to login via http://retsmd.com with the url, username and password. 我能够通过url,用户名和密码通过http://retsmd.com登录。 I really need to get my listings in the format of CSV.
我确实需要以CSV格式获取列表。
PLEASE HELP 请帮忙
I do have curl installed on my server, I checked with this method: 我的服务器上确实安装了curl,我使用以下方法进行了检查:
A response code of 0 usually indicates that your server failed to open a connection with the server, likely due to firewall issues between you and them. 响应代码0通常表示您的服务器无法打开与服务器的连接,这很可能是由于您与它们之间的防火墙问题所致。 Some RETS servers still run on a port 6103, so if your server (hosting company, etc.) prevent outbound connections from being opened on that port, that could be the cause for what you're seeing.
某些RETS服务器仍在端口6103上运行,因此,如果您的服务器(托管公司等)阻止在该端口上打开出站连接,则可能是您所看到的原因。
I'd recommend trying your code example from a different server or computer that doesn't have any connection restrictions. 我建议您从没有任何连接限制的另一台服务器或计算机上尝试您的代码示例。 You could also try https://retsmd.com/auth as a way to verify that the credentials you've been given will work (assuming your local environment has what it needs for PHRETS to run).
您也可以尝试https://retsmd.com/auth作为验证给您的凭据是否可以正常工作的一种方法(假设您的本地环境具有运行PHRETS所需的条件)。
Adding to troydavisson's answer, 除了troydavisson的答案,
You can include the following extra line of code to get the log of your connection for checking the issue. 您可以包括以下额外的代码行,以获取连接日志以检查问题。
// start rets connection
$rets = new phRETS;
$rets->SetParam('debug_mode', true);//extra line of code to get log
You will get full log in the rets_debug.txt file. 您将在rets_debug.txt文件中获得完整的日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.