2017-07-09 44 views
1

我試圖讓使用我從這裏下載PHRETS我所有的MLS通過PHP列出連接到RETS:PHP - 廣東話通過PHRETS

​​

,我用這個例子來下載我的列表成csv格式:

https://github.com/troydavisson/PHRETS/wiki/Connect,%20download%20listing%20data%20in%20CSV%20format,%20disconnect

我從我的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?

+1

你爲什麼從dangodev的Github下載PHRETS庫?在這裏使用官方的PHRETS Github:https://github.com/troydavisson/PHRETS。也請按照那裏的文檔。此外,還有2個PHRETS分支:1.x和2.0。每個文檔都有不同的文檔。 –

回答

3

0的響應代碼通常表明你的服務器無法打開一個連接服務器,可能是由於你和他們之間的防火牆問題。一些RETS服務器仍然在端口6103上運行,所以如果你的服務器(託管公司等)阻止在該端口上打開出站連接,這可能是你看到的原因。

我建議從不具有任何連接限制的不同服務器或計算機上嘗試您的代碼示例。您也可以嘗試使用https://retsmd.com/auth作爲驗證您提供的憑據是否有效的方式(假設您的本地環境具有運行PHRETS所需的憑據)。

1

添加到troydavisson的回答,

可以包括下列代碼額外的行,讓您檢查問題的連接的日誌。

// start rets connection 
$rets = new phRETS; 
$rets->SetParam('debug_mode', true);//extra line of code to get log 

您將獲得完整登錄rets_debug.txt文件。