2011-08-19 154 views
0

我使用cURL爲客戶創建了一個API。我剛搬到一個新的服務器這個域,現在的API不起作用。似乎一切工作都很好模塊明智,但我不能得到它的工作:cURL在此服務器上未找到請求的URL /api/process.php

這是我得到的迴應。

Array ( 
[url] => https://www.1800pay.com/api/process.php 
[content_type] => text/html; charset=iso-8859-1 
[http_code] => 404 
[header_size] => 179 
[request_size] => 506 
[filetime] => -1 
[ssl_verify_result] => 0 
[redirect_count] => 0 
[total_time] => 0.038607 
[namelookup_time] => 0.002688 
[connect_time] => 0.002737 
[pretransfer_time] => 0.038372 
[size_upload] => 0 
[size_download] => 294 
[speed_download] => 7615 
[speed_upload] => 0 
[download_content_length] => 294 
[upload_content_length] => 0 
[starttransfer_time] => 0.038597 
[redirect_time] => 0) 
Curl error: 

Not Found 

The requested URL /api/process.php was not found on this server. 

Apache/2.2.3 (CentOS) Server at www.1800pay.com Port 443 

代碼中使用:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "https://www.1800pay.com/api/process.php"); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); 
curl_setopt($ch, CURLOPT_TIMEOUT, 15); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
//curl_setopt($ch, CURLOPT_VERBOSE, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $output_transaction); 
curl_setopt($ch, CURLOPT_POST, 1); 

if (!($data = curl_exec($ch))) {print_r(curl_error($ch));echo "error"; 
return ERROR; 
} 
print_r(curl_getinfo($ch)); 
echo 'Curl error: ' . curl_error($ch); 
curl_close($ch); 

print_r($data); 

感謝您的幫助:) 是的文件存在於服務器.....:|

+0

Curl正在嘗試44?或者在複製粘貼時錯過了3個? – Alex

+0

粘貼pb我會修復該問題,謝謝 – Outcast

+0

1800pay.com解決適當的IP?你已禁用SSL驗證,所以你可以連接到幾乎任何服務器。同樣,檢查服務器的錯誤日誌,它會說明它試圖檢查process.php文件的目錄。 –

回答

0

答案在響應內..一個未發現的錯誤就是這樣。只要確保文件api/process.php存在於新域中即可。

+0

謝謝,但該文件位於服務器上,並位於代碼提及的地方:)。 – Outcast

0

我不知道你的問題是什麼,但是當我嘗試使用捲曲的網址是:

function curl_get($url) 
    { 
     $curl_handle = curl_init(); 
     curl_setopt($curl_handle, CURLOPT_URL, $url); 
     curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); 
     curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE); 
     curl_setopt($curl_handle, CURLOPT_COOKIEJAR, "cookie.txt"); 
     curl_setopt($curl_handle, CURLOPT_COOKIEFILE, "cookie.txt"); 
     //curl_setopt($curl_handle, CURLOPT_USERPWD, $co.":".$apikey); 
     curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($curl_handle, CURLOPT_DNS_USE_GLOBAL_CACHE, FALSE); 
     $buffer = curl_exec($curl_handle); 
     $error = curl_error($curl_handle); 
     curl_close($curl_handle); 
     //if (empty($buffer)) 
      //echo "No response from server: ".$error; 
     //else 

     return $buffer; 
    } 

我得到這個:

錯誤[代碼:1043]付款()鍵 - 錯誤的數據

+0

是的,這是正常的,因爲我沒有給你的API密鑰上面有帳戶信息。但是,如果你得到了答案,這意味着API工作並找到該文件,但在服務器上運行該PHP腳本本身不起作用。有趣。 – Outcast

+0

也許嘗試刪除HEADER,0子句? –

+0

是你的output_transaction一個關聯數組嗎? –

相關問題