2015-09-28 167 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

相关问题