|
config/rest.php中的设置为
$config['rest_auth'] = 'digest';
$config['rest_valid_logins'] = array('admin' => '1234');
然后程序为
curl_setopt($ch, CURLOPT_URL, "http://localhost/index.php/api/example/user/id/1/format/json");
curl_setopt($ch, CURLOPT_USERPWD, 'admin:1234');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result= curl_exec($ch);
curl_close($ch);
var_dump(json_decode($result));
结果报“Not authorized”
如果设置为$config['rest_auth'] = '';
结果返回正确
请问是哪里没设好,还是程序上还有哪里没写好?
|
|