drbd65446 2015-11-26 14:15
浏览 59

在BlueMix上的php环境中使用curl_init()时出错

I use the PHP runtime on Bluemix. In my solution, I need to invoke the external API available on the Internet on port 3000.

I used curl to manage the API invocation using the following code:

$endPoint="http://".$this->server.":".$this->port.$endPoint;
$session = curl_init($endPoint);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($session);

In the Bluemix log I found the following error:

Got error 'PHP message: PHP Fatal error: Call to undefined function
curl_init() in /home/vcap/app/htdocs/include/service.php on line 50
',
referer: http://m2msite.mybluemix.net/login.php

It does not seem to be a defined curl library inside my runtime.
I do not found any documentation on how to define the curl library in a Bluemix runtime.

Can anyone help me to configure my runtime in a correct way?

Many thanks in advance

  • 写回答

2条回答 默认 最新

  • douqianxun8540 2015-11-26 14:41
    关注

    I found the solution.

    under the project root I create a directory .bp-config
    Inside the directory I create a file option.json with the following content:

    {
        "PHP_EXTENSIONS": ["mysqli","curl"]
    }
    

    mysqli for mysql library and curl for the curl library.

    So now I am able to use curl library inside my project

    Has anyone the link for a complete documentation around this configuration steps ?

    Ciao

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog