用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1225|回复: 1
收起左侧

请教用curl密码登录GET的问题

[复制链接]
发表于 2014-5-1 17:48:34 | 显示全部楼层 |阅读模式
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'] = '';
结果返回正确

请问是哪里没设好,还是程序上还有哪里没写好?


 楼主| 发表于 2014-5-9 11:47:30 | 显示全部楼层
自己顶一下

本版积分规则