我正在尝试使用PHRETS通过PHP获取我所有的MLS清单,我从这里下载了以下内容:
https://github.com/dangodev/PHRETS-Example/blob/master/lib/phrets.php
我用这个例子将我的清单下载成csv格式:
我从我的MLS板获得了RETS URL,用户名和密码,但我仍然无法连接。
在这里调用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;
}当我转到库并查看Connect方法时,该代码在这里返回false:
// make request to Login transaction
$result = $this->RETSRequest($this->capability_url['Login']);
if (!$result) {
return false;
}当我查看我的RETSRequest方法时,它在这里返回false,因为响应代码是0而不是200
if ($response_code != 200) {
$this->set_error_info("http", $response_code, $response_body);
return false;
}这里是它试图连接的地方:
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);为什么我不能联系?
我能够用网址、用户名和密码通过http://retsmd.com登录。我真的需要得到我的列表格式的CSV。
请帮帮忙
我确实在我的服务器上安装了curl,我使用以下方法检查:
发布于 2017-08-16 00:34:07
响应代码0通常表示服务器无法打开与服务器的连接,可能是由于您与服务器之间存在防火墙问题。有些RETS服务器仍然运行在端口6103上,所以如果您的服务器(托管公司等)防止在该端口上打开出站连接,这可能是您看到的原因。
我建议在没有任何连接限制的不同服务器或计算机上尝试您的代码示例。您还可以尝试使用https://retsmd.com/auth来验证您所获得的凭据是否正常工作(假设您的本地环境具备运行PHRETS所需的条件)。
发布于 2017-12-13 07:41:54
再加上特雷达维森的答案,
您可以包括以下额外代码行,以获取用于检查问题的连接日志。
// start rets connection
$rets = new phRETS;
$rets->SetParam('debug_mode', true);//extra line of code to get log您将在rets_debug.txt文件中获得完整的日志。
https://stackoverflow.com/questions/44998675
复制相似问题