我正在尝试实现 Phil Sturgeon 的休息服务器并学习使用 api 密钥进行身份验证。我再次使用 Phil Sturgeon 的 rest 客户端和 curl 库。程序在获取和删除请求方面工作正常,但在尝试发布和其他剩余方法时,它会抛出“未授权”响应。当我尝试使用摘要身份验证时(这里我使用 chrome 高级 rest 客户端进行测试)用户名和密码不匹配,浏览器总是显示登录表单。这是我的卷曲测试仪
function rest_client_example($id)
{
$this->load->library('rest', array(
'server' => 'http://localhost:81/restserver/index.php/api/example/',
'http_user' => 'admin',
'http_pass' => '1234',
'http_auth' => 'digest', // or 'digest'
));
$user = $this->rest->put('user', array('id' => $id, 'X-API-KEY' => 'aa72dfaa70d6aa6c2c8d26b82c08d26db979f2f0'), 'application/json');
print_r($user);exit;
echo $user->name;
}
我正在使用该其余服务器捆绑包中包含的默认示例类