dosf40815 2015-07-28 14:07 采纳率: 100%
浏览 27
已采纳

Cloud9上的PHP PECL扩展是否有效?

I wanted to test some basic http_request functions (ie: echo http_request(HTTP_METH_GET,"http://www.example.com");) but PECL extensions dont seem to be working in Cloud9's IDE. Which is strange because the code hints show http_request and http_response_code are both available making it seem as if PECL extentions are installed. Is there a trick that i'm missing? thanks

  • 写回答

1条回答 默认 最新

  • dqxyh48864 2015-07-28 14:34
    关注

    You need to install these packages first:

    sudo apt-get install php-http
    sudo apt-get install php5-dev
    sudo apt-get install libcurl3
    sudo apt-get install libpcre3-dev
    sudo apt-get install libcurl4-openssl-dev
    sudo pecl install raphf 
    sudo pecl install pecl_http-1.7.6
    

    Then change your php.ini configuration (add lines with "extension" and change enable_dl from Off to On):

    enable_dl = On
    extension = raphf.so
    extension = propro.so
    extension = hash.so
    extension = iconv.so
    extension = json.so
    extension = http.so
    

    Then stop and start project and PECL/HTTP should be working correct.

    I tried this code and works fine:

    $r = new HttpRequest('http://rss.cnn.com/rss/edition.rss', HttpRequest::METH_GET);
    $r->addQueryData(array('category' => 3));
    $r->send();
    if ($r->getResponseCode() == 200)
        print $r->getResponseBody();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败