我試圖讓使用我從這裏下載PHRETS我所有的MLS通過PHP列出連接到RETS:PHP - 廣東話通過PHRETS
,我用這個例子來下載我的列表成csv格式:
我從我的MLS板RETS網址,用戶名和密碼,但我仍然無法連接。當調用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;
}
當我轉到圖書館,並期待在方法連接時,該代碼返回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與url,用戶名和密碼登錄。我真的需要以CSV格式獲取我的列表。
請幫助
我做我的服務器上有捲曲的安裝,我用這種方法檢查:
Check to see if cURL is installed locally?
你爲什麼從dangodev的Github下載PHRETS庫?在這裏使用官方的PHRETS Github:https://github.com/troydavisson/PHRETS。也請按照那裏的文檔。此外,還有2個PHRETS分支:1.x和2.0。每個文檔都有不同的文檔。 –