Php debian中的cURL设置
我最近设置了一个cURL脚本,并在windowsxampp环境下进行了测试。 现在我想把它带到我们的Debian机器上,但它无论如何都不工作 我认为这与php5卷曲设置有关,但我无法让它工作。 这是Windows计算机上php信息的输出: 这是Debian机器的php信息的输出: 这是在Windows计算机上工作,但在Debian上不工作的代码:Php debian中的cURL设置,php,curl,xampp,debian,Php,Curl,Xampp,Debian,我最近设置了一个cURL脚本,并在windowsxampp环境下进行了测试。 现在我想把它带到我们的Debian机器上,但它无论如何都不工作 我认为这与php5卷曲设置有关,但我无法让它工作。 这是Windows计算机上php信息的输出: 这是Debian机器的php信息的输出: 这是在Windows计算机上工作,但在Debian上不工作的代码: <?php // Begin unifi authorisatie session_start(); function sendAu
<?php
// Begin unifi authorisatie
session_start();
function sendAuthorization($id, $minutes)
{
$unifiServer = "https://127.0.0.1:8443"; // unifi server
$unifiUser = "admin"; // unifi admin naam
$unifiPass = "xxxxxx"; // unifi admin wachtwoord
// Start Curl for login
$ch = curl_init();
// We are posting data
curl_setopt($ch, CURLOPT_POST, TRUE);
// Set up cookies
$cookie_file = "/tmp/unifi_cookie";
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
// Allow Self Signed Certs
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// Force TLSv1 only
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
// Login to the UniFi controller
curl_setopt($ch, CURLOPT_URL, "$unifiServer/login");
curl_setopt($ch, CURLOPT_POSTFIELDS,
"login=login&username=$unifiUser&password=$unifiPass");
// send login command
curl_exec ($ch);
// Send user to authorize and the time allowed
$data = json_encode(array(
'cmd'=>'authorize-guest',
'mac'=>$id,
'minutes'=>$minutes));
// Send the command to the API
curl_setopt($ch, CURLOPT_URL, $unifiServer.'/api/s/default/cmd/stamgr'); // Vergeet de site niet aan te passen bij een nieuwe locatie
curl_setopt($ch, CURLOPT_POSTFIELDS, 'json='.$data);
curl_exec ($ch);
// Logout of the UniFi Controller
curl_setopt($ch, CURLOPT_URL, $unifiServer.'/logout');
curl_exec ($ch);
curl_close ($ch);
unset($ch);
}
if ($_SESSION['loggingin'] == "unique key") // Check to see if the form has been posted to
{
ob_start();
sendAuthorization($_SESSION['id'], (180*24*60)); //authorizing user for 180 days
ob_end_clean();
unset($_SESSION['loggingin']);
}
?>
我认为这与缺少的https协议有关,但是如何为cURL安装它?它会给您带来任何错误吗?你的
/tmp/unifi_cookie
是什么?您有权访问/tmp
文件夹吗?我看到您试图通过https
访问url,而您的debian服务器不支持ssl
。代码似乎很好。@Alex我有/tmp文件夹的访问权限,我还认为https有问题,有没有办法安装这个。请记住,我不是linux专家,所以请原谅我这个愚蠢的问题:)也许你应该问一个问题,或者尝试安装libssl
库。