| 제목 | restclient 사용중 404에러 질문 | ||
|---|---|---|---|
| 카테고리 | PHP | ||
| 글쓴이 | firekuma | 작성시각 | 2017/09/27 17:27:50 |
|
|
|||
|
안녕하세요. rest api 구현할려고, 아래 사이트 라이브러리를 갖다 테스트 중인데요. (CI버전은 3.0 php버전은 5.6 입니다.)
서버는 https://github.com/chriskacerguis/codeigniter-restserver 클라이언트는 https://github.com/philsturgeon/codeigniter-restclient
서버는 제공되는 샘플소스를 올려서 테스트해본 결과 잘 나오더라구요. 문제는 클라이언트 라이브러리를 올려서 테스트해 본 결과 404에러만 뜨네요.
api 형식은 http://rest.xxxxco.kr/api/example/users/id/1 이렇고, 클라이언트에서는 http://rest.xxxxco.kr/rest/rest_client_example/1 형식으로 상기 api 주소로 호출 하였습니다. 클라이언트 소스는 아래와 같구요.
<!--컨트롤러 함수--> function rest_client_example($id) { $this->load->library('rest', array( 'server' => 'http://rest.xxxx.co.kr/', //'http_user' => '', //'http_pass' => '', //'http_auth' => '' // or 'digest' )); $user = $this->rest->get('api/example/users', array('id' => $id), 'json'); // var_dump($user); $this->rest->debug(); } <!--컨트롤러 함수 끝-->
디버깅을 찍으면 Call details
Array
(
[url] => http://rest.xxxx.co.kr/api/example/users?id=1
[content_type] => text/html; charset=UTF-8
[http_code] => 404
[header_size] => 141
[request_size] => 78
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.013323
[namelookup_time] => 0.002761
[connect_time] => 0.007237
[pretransfer_time] => 0.007238
[size_upload] => 0
[size_download] => 1130
[speed_download] => 84815
[speed_upload] => 0
[download_content_length] => 1130
[upload_content_length] => 0
[starttransfer_time] => 0.013311
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => xxx.xxx.xxx.xxx
[certinfo] => Array
(
)
)
제가 무슨 잘못을 하고 있는지 도저히 잘 모르겠어요 ㅠㅠ 고수님들의 친절한 답변 부탁드립니다. ㅠㅠ
아님, 더 좋은 라이브러리는 없는지도 궁금합니다. ..
|
|||
| 다음글 | php 버전 업그레이드 하려고 합니다. (11) | ||
| 이전글 | [svn] svn revision 번호는 똑같은데 내용... (3) | ||
|
한대승(불의회상)
/
2017/09/27 18:05:10 /
추천
0
|
|
firekuma
/
2017/09/28 08:40:22 /
추천
0
답변감사합니다.
해결했습니다. 아 진짜 무식한게 죈가봐요 ㅠㅠ 처리하는 서버에서 rest.xxxx.co.kr이란 도메인이 인식이 안되니 당연히 안되는 거였죠..ㅠㅠ /etc/hosts 설정해주니 잘 되네요. 폐끼쳐서 죄송합니다.
|
호출해야 하는 주소형식은 http://rest.xxxx.co.kr/api/example/users/id/1 인데 실제 호출되는 주소는 http://rest.xxxx.co.kr/api/example/users?id=1 군요.
호출 방법을 바꿔서 테스트 해보세요.