cakephp restful服务

cakephp restful服务,cakephp,cakephp-2.0,Cakephp,Cakephp 2.0,我已经创建了一个我想向外界公开的方法。我的应用程序由ACL控制。所以,要使用restful服务,您需要通过url将get或post中的数据发送到该方法。 http://mysite.com?action=this&data=thisetc 但是我想我也需要发送用户名和密码,不是吗?如果我这样做了,那么我应该在哪里添加它 **我试过什么** <?php $ch = curl_init("http://test.local/sites/loginData"); curl_setopt($ch

我已经创建了一个我想向外界公开的方法。我的应用程序由ACL控制。所以,要使用restful服务,您需要通过url将get或post中的数据发送到该方法。
http://mysite.com?action=this&data=this
etc 但是我想我也需要发送用户名和密码,不是吗?如果我这样做了,那么我应该在哪里添加它

**我试过什么**

<?php
$ch = curl_init("http://test.local/sites/loginData");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, 'user:password'); 
// sending username and pwd.                   
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);                          
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);                           
curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');
curl_setopt($curl, CURLINFO_HEADER_OUT, true);

$output = curl_exec($ch);
print_r($output);      
curl_close($ch);
echo '<br><br>';
echo $output;
?> 


但是它没有向我显示任何响应

如果您使用的是http basic auth,那么您必须在CakePHP中正确配置auth组件才能使用该身份验证机制

有关身份验证,请参阅


这是通过ACL进行授权。

如果使用http basic auth,则必须在CakePHP中正确配置auth组件,以使用该身份验证机制

有关身份验证,请参阅

这是通过ACL进行授权