Skip to content

Commit ae7f869

Browse files
committed
curl : more info on error (curl not working on windows)
1 parent 80b23f4 commit ae7f869

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools.php

+17
Original file line numberDiff line numberDiff line change
@@ -1662,19 +1662,36 @@ public static function isWindowsServer() {
16621662

16631663
/**
16641664
* gets the data from a URL
1665+
*
1666+
* On Windows you need php curl extension + php in PATH
1667+
* https://www.howtosolutions.net/2021/09/fixing-php-curl-extension-not-loading-when-enabled-windows/
1668+
*
1669+
* @param string $url
1670+
* @param int $timeout in seconds
1671+
* @return FALSE on failure, result on success
16651672
*/
16661673
public static function getUrlContent($url, $timeout = 5) {
16671674
$ch = curl_init();
16681675
curl_setopt($ch, CURLOPT_URL, $url);
16691676
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
16701677
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
16711678
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
1679+
#curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
16721680

16731681
if (!empty(Constants::$proxy)) {
16741682
curl_setopt($ch, CURLOPT_PROXY, Constants::$proxy);
16751683
#curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
16761684
}
16771685
$data = curl_exec($ch);
1686+
1687+
if (FALSE === $data) {
1688+
if (false == extension_loaded("curl")) {
1689+
self::$logger->error("getUrlContent(): PHP curl extension missing !");
1690+
}
1691+
self::$logger->error("getUrlContent($url)");
1692+
//$msg = var_export(curl_getinfo($ch), true);
1693+
//self::$logger->error("$msg");
1694+
}
16781695
curl_close($ch);
16791696
return $data;
16801697
}

0 commit comments

Comments
 (0)