您好我在这里遇到问题,当我尝试在我的服务器上执行curl时出现500内部服务器错误。我联系过支持,他们声称这是我的.htaccess文件,他们无能为力。
这是我的代码:
$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 :(得分:1)
您必须使用curl处理https。最简单的选择是用
关闭它CURLOPT_SSL_VERIFYPEER => 0
因为如果你不这样做,你将得到一个空的结果。如果要处理结果,则会抛出500错误,因为它是空的。
答案 1 :(得分:-2)
您在curl网址中使用https协议
$url = "https://".$server_ip.":".$port."/api/fusion/tp/".$api_key;
应该使用http协议。