MAC上的PHP CURL - 当curl_exec为localhost时挂起:1055

时间:2016-09-15 06:19:06

标签: php curl

我一直试图在localhost:1055上调用我的网站,我的curl_exec调用挂起。当我调用外部URL时,它工作正常,我得到一个响应。我试图关闭我的防火墙,我已经阅读了关于堆栈溢出的所有文章,但我似乎没有得到这个问题的答案。我看过一个帖子,其中有人有类似的问题,但没有解决方案。有人可以帮忙吗?

我在OS X Al Capitan版本10.11.6(15G1004)上使用PHP 5.6,我正在使用在端口1055上运行的PHPstorm内部Web服务器。这是我的代码:

    <?php

    function __singleRequestSending($data, $options = array()) {

    // array of curl handles
    $ch = curl_init();
    // data to be returned

    curl_setopt($ch, CURLOPT_URL, $data["url"]);
    //curl_setopt($ch, CURLOPT_PORT, 1055);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode($data["data"]));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    //execute post
    $result = curl_exec($ch);

    //close connection
    curl_close($ch);

    return $result;
    }

    $data = array(
        'url' => "http://localhost:1055/info.php",
        'data' => "abc" 
    );

    $res = __singleRequestSending($data);
    echo 123;
    echo "<pre>";
    var_dump($res);
    print_r($res);
   exit;


    ?>    

0 个答案:

没有答案
相关问题