我正在开发一个使用 CURL PHP 的项目,但我无法安装 curl 扩展,因为我不是“Nitrous.io”框的 root 用户。
在 Nitrous.io PHP Box 中安装 CURL PHP 还有另一种选择吗?
提前致谢!
只需在 nitrous.io 盒子上重新安装 php5 包
$ parts update
$ parts install php5
$ php -m | grep curl
curl
$ php -r 'echo curl_version()["version"] . PHP_EOL;'
7.22.0
我对 Nitrious.io 不熟悉,但如果您无法为您的项目访问/安装 curl,您将不得不直接联系 Nitrious 以了解如何使用 curl。
此外,您也许可以使用fsocketopen来解决您的问题。例子:
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}