2015-09-28 163 views
0

您好我在這裏有一個問題,當我嘗試在我的服務器上執行curl時,出現500內部服務器錯誤。我聯繫了支持人員,他們聲稱這是我的.htaccess文件,他們無能爲力。嘗試執行CURL時發生500內部服務器錯誤

這是我的代碼:

$api_key = 'f7cb125a449f4f908931f360ac33b52a'; 
$server_ip = '162.13.170.20'; 
$port = '5000'; 
$url = "https://".$server_ip.":".$port."/api/fusion/tp/".$api_key; 

// Get cURL resource 
$curl = curl_init(); 
// Set some options - we are passing in a useragent too here 
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1, 
    CURLOPT_URL => $url, 
    CURLOPT_USERAGENT => 'myTicketGH', 
    CURLOPT_POST => true, 
    CURLOPT_POSTFIELDS => array(
     'kuwaita' => 'malipo', 
     'amount' => $calculated_total_cost, 
     'mno' => $network, 
     'msisdn' => $phone 
    ) 
)); 
// Send the request & save response to $resp 
$resp = curl_exec($curl); 
// Close request to clear up some resources 
curl_close($curl); 

return [ 
    'response' => $resp 
]; 

這是我的.htaccess文件:

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    Options +FollowSymLinks 
    RewriteEngine on 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 

    RewriteRule . index.php [L] 

    RewriteEngine On 
    RewriteCond %{HTTP:Authorization} . 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
</IfModule> 

是否有使用curl的laravel方式?因爲我無法理解我的.htaccess文件如何出現問題,但我的應用程序仍在運行。

我接觸的支持,顯然這是我的error_log:

[Tue Sep 29 09:31:20 2015] [warn] [client 69.195.125.1] mod_fcgid: read data timeout in 40 seconds 
[Tue Sep 29 09:31:20 2015] [error] [client 69.195.125.1] Premature end of script headers: index.php 
[Tue Sep 29 09:31:20 2015] [error] [client 69.195.125.1] File does not exist: /home/mytickf1/public_html/500.shtml 
[Tue Sep 29 09:31:26 2015] [warn] mod_fcgid: process 14879 graceful kill fail, sending SIGKILL 

我還要補充一點,我的服務器使用一個專用的IP地址。

+0

你的錯誤日誌說什麼? –

+0

在我的cPanel的錯誤日誌頁面上看不到任何相關的錯誤。 – user3718908

+0

嘗試啓用Curl詳細'curl_setopt($ curlhandle,CURLOPT_VERBOSE,true);'是否輸出有意義的東西? –

回答

1

你必須用curl處理https。最簡單的選擇是關閉它

CURLOPT_SSL_VERIFYPEER => 0 

因爲如果你不這樣做,你會得到一個空的結果。當您想要處理結果時,會拋出500錯誤,因爲它是空的。

+0

也嘗試了這個,無法讓它工作,相同的響應, – user3718908

+0

我測試了您的代碼與谷歌IP和我的解決方案與您的代碼一起工作。 – mimo

+0

那麼它可能是我發佈的服務器,而不是我的代碼? – user3718908

-2

您正在使用您的捲曲URL

$url = "https://".$server_ip.":".$port."/api/fusion/tp/".$api_key; 

https協議應與HTTP協議的工作。

+0

我不明白,你是說CURL不能使用https嗎? – user3718908

+0

不,我只是懷疑https可能是罪魁禍首。你是否也設置授權標題?請分享錯誤日誌 – Azhar

+0

我查了錯誤日誌,這裏沒有任何關於這個錯誤的地方。 – user3718908

相關問題