CI 묻고 답하기

제목 restful 값이 안넘어오네요..
글쓴이 골때마추기 작성시각 2015/03/10 20:14:13
댓글 : 4 추천 : 0 스크랩 : 0 조회수 : 17757   RSS
require (APPPATH . 'libraries/REST_Controller.php');
class Test extends REST_Controller {
    function user_get($id) {
        $data = array (
                'returned - GET : ' . $this->get ( 'id' ) 
        );
        $this->response ( $data );
    }
    function user_post() {
        $data = array (
                'returned - POST: ' . $this->post ( 'id' ) 
        );
        $this->response ( $data );
    }
    function user_put() {
        $data = array (
                'returned - PUT : ' . $this->put ( 'id' ) 
        );
        $this->response ( $data );
    }
    function user_delete() {
        $data = array (
                'returned - DELETE : ' . $this->delete ( 'id' ) 
        );
        $this->response ( $data );
    }
}
서버 파일

<?php

class Client extends CI_Controller {
    function rest_client_example($id)
    {
    $this->load->library('rest', array(
        'server' => 'http://localhost/code/index.php?/test/'
    ));
     
    $user = $this->rest->get('user', array('id' => $id), 'json');
     
    echo $user;
    }
}
Client 파일입니다~
값이 넘어오는지 안오는지만 궁금해서 계속 날려보고 있는데
아무 값도 안나오네요
하지만 url에다가 직접 http://localhost/code/index.php?/test/id/10
이라고 치면 값은 잘나옵니다.
왜 아무것도 안나오는지 궁금하네요
혼자 공부하면서 하는데 많이 막히네요 
조언 부탁드립니다.
 
 다음글 ajax로 받아들인 json을 그냥 post로 받을 수... (2)
 이전글 이 내용과 같이 오라클 프로시져 사용하는 방법을 알려주... (1)

댓글

변종원(웅파) / 2015/03/10 22:43:06 / 추천 0
질문에 답이 있는데요?

서버의 주소를 직접 치면 데이터 잘 나오고 rest client 프로그램 쓰면 안나오고... ^^
(주소도 틀리네요)

전 curl library 사용해서 테스트 합니다. 
골때마추기 / 2015/03/10 23:23:52 / 추천 0
@변종원
class Client extends CI_Controller {
    function rest_client_example($id)
    {
    $this->load->library('rest', array(
        'server' => 'http://localhost/code/index.php?/test/id/10'
    ));
     
    $user = $this->rest->get('user', array('id' => $id), 'json');
     
    echo $user;
    }
}
말씀하신대로 주소를 바꿔줘도 똑같네요..ㅠ 값이 안넘어오는게..

http://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814
여기보고 따라한건데 잘안되네요..
curl library가 사용하기 더 쉽나요!?
 
한대승(불의회상) / 2015/03/11 09:10:47 / 추천 0
골때마추기// Restful 서비스에 대한 이해가 필요 합니다.
아래 자료가 도움이 될 것 같군요.

http://cikorea.net/file/view/209/page/1
골때마추기 / 2015/03/11 11:37:51 / 추천 0
@한대승 감사합니다. 부족한 부분을 공부할 수 있겠네요..