【问题标题】:How can I remove cURL error in GAE google appengine如何删除 GAE google appengine 中的 cURL 错误
【发布时间】:2016-02-09 12:05:58
【问题描述】:

当我在 Google appengine gae 上上传我的文件时,我在 php 文件 Fatal error: Call to undefined function curl_init() 中遇到了这个错误,然后我收到了这个错误:

我正在 PHP 中尝试这个 cURL

function getpage($url)
{
// fetch data
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; Android 5.0; ASUS_T00J Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko)      Chrome/44.0.2403.133 Mobile Safari/537.36');

$data = curl_exec($curl);
curl_close($curl);
//return preg_replace('~[\r\n]+~', ' ', $data);
return $data;
}

在这个line $curl = curl_init();上发现错误

如何消除此错误?

【问题讨论】:

    标签: php google-app-engine curl


    【解决方案1】:

    你需要安装 curl。

    窗户: 转到您的 php.ini 文件并删除 ;从以下行的开头标记:

    ;extension=php_curl.dll

    Ubuntu: ubuntu 13.0 及更高版本,只需使用 debundled 包。在终端中输入以下内容进行安装,不要忘记重启服务器。

    sudo apt-get install php5-curl

    在 GAE 上:

    启用 cURL_lite

    1. 将指令google_app_engine.enable_curl_lite = "1" 添加到您的php.ini 文件中。

    注意事项

    • cURL_lite 只允许调用 HTTP 或 HTTPS 客户端
    • 如果没有将运行时调整为 php55,cURL_lite 无法在我的本地开发服务器上运行,但它适用于生产环境中的 php
    • cURL_lite 不需要应用程序启用计费功能

    启用 cURL

    1. 将 app.yaml 中的运行时设置从 php 更改为 php55。
    2. 将指令扩展 =“curl.so”添加到您的 php.ini 文件中。

    注意事项

    • cURL 仅在 App Engine 的 PHP 5.5 实现中可用
    • cURL 只能由启用了计费的应用程序使用
    • cURL 受 App Engine 套接字的限制,但包括:
      • 仅限于定位 Google 域
      • 可以在 2 分钟不活动后回收

    【讨论】:

    • 但我的文件夹中没有任何 php.ini 文件
    • php.ini 是您的主要配置文件。你用这个文件启动 php。 (信息:secure.php.net/manual/de/configuration.file.php)您使用的是 Windows,还是 Linux,Unix Maschine?
    • windows 但我正在尝试为 Google gae 应用引擎设置
    • 在 Windows 上,php.ini 位于 PHP 文件夹的根目录中。您需要编辑文件以允许/加载 Curl 扩展名。没有你就不能使用 curl。
    • 我只有 app.yaml 文件
    猜你喜欢
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    • 2011-06-27
    • 2016-10-22
    • 2011-08-11
    • 1970-01-01
    • 1970-01-01
    • 2012-01-22
    相关资源
    最近更新 更多