Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Curl无法在同一服务器中获得响应_Php_Web Services_Curl_Yii - Fatal编程技术网

Php Curl无法在同一服务器中获得响应

Php Curl无法在同一服务器中获得响应,php,web-services,curl,yii,Php,Web Services,Curl,Yii,我在应用程序中使用curl 我在DefaultController中的功能: 在serviceTypeMasterController中: 我正在调用curlURL中localhost的URL。但是curl没有给出任何反应。它只给我响应,不包含任何数据 怎么了 通常,该响应是在页面/服务不存在的情况下进行的。是否确实在端口83而不是默认80上运行服务器,并且url解析为actionTest而不是test方法?是,我在端口83上运行。行动规则有问题。我的方法位于已验证的用户区域。当我将action

我在应用程序中使用curl

我在DefaultController中的功能:

在serviceTypeMasterController中:

我正在调用curlURL中localhost的URL。但是curl没有给出任何反应。它只给我响应,不包含任何数据


怎么了

通常,该响应是在页面/服务不存在的情况下进行的。是否确实在端口83而不是默认80上运行服务器,并且url解析为actionTest而不是test方法?

是,我在端口83上运行。行动规则有问题。我的方法位于已验证的用户区域。当我将actionTest公开时,它被调用。但我不知道如何允许经过身份验证的用户访问curl中受保护的方法?
public function actionWebServices()
{

    $data = array("account" => "1234", "dob" => "30051987", "site" => "mytestsite.com");
    $fields='';
    foreach ($data as $key => $value) 
        {
            $fields .= $key . '/' . $value . '/';
        }
    rtrim($fields, '&');

    $u='admin';
    $p='admin123';
    $url='localhost:83/Working-copy/mysite/ServiceTypeMaster/Test';

     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 1);  
     curl_setopt($ch, CURLOPT_POST, 1);  
     curl_setopt($ch, CURLOPT_VERBOSE, 1);  
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);    
     curl_setopt($ch, CURLINFO_HEADER_OUT, 1); 
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($ch, CURLOPT_USERPWD, $u.':'.$p);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, count($data));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

     session_write_close();

     $result = curl_exec($ch);

     curl_close($ch);

     session_start();

     return $result;

}
public function actionTest()
{
    echo "test";
}