2014-07-06 4 views
1

Phil Sturgeon의 나머지 서버를 구현하고 api 키로 인증하는 방법을 배우려고합니다. 나는 Phil Sturgeon에 의해 휴식 클라이언트와 컬 라이브러리를 사용하고 있습니다. 프로그램은 get과 delete request로 잘 작동하지만 post와 다른 남은 메소드를 시도 할 때 "not authorized"응답을 던집니다. 그리고 내가 다이제스트 인증을 사용하려고 할 때 (여기에 Chrome 고급 검사 클라이언트를 사용하여 테스트) 사용자 이름과 비밀번호가 일치하지 않아 브라우저가 로그인 양식을 항상 표시합니다. 여기 내 컬 테스터작동하지 않지만 다른 방법은 작동하지 않습니다. phill로 편안한 서버

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; 
} 

내가

답변

0

패스 API 키 header

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', 
      'api_key' => 'aa72dfaa70d6aa6c2c8d26b82c08d26db979f2f0', 
      'api_name' => 'X-API-KEY', 


     )); 

     $user = $this->rest->put('user', array('id' => $id), 'application/json'); 
     print_r($user);exit; 
     echo $user->name; 
    } 
에 그 나머지 서버 번들에 포함 된 기본 예제 클래스를 사용하고 있습니다