iOSでWebサービスを初めて使用しました。 RESTが私の最初の選択であり、コードイグナイターを使用してそれを形成しました。Rest API Webサービス - iOS
{"users":[{"id":"1","name":"Porcopio","age":"99"},{"id":"2","name":"Name1","age":"24"},{"id":"3","name":"Porcopio","age":"99"},{"id":"4","name":"Porcopio","age":"99"},{"id":"5","name":"Luna","age":"99"}]}
、これは私にRKRequestを使用して大きな出力が得られます。http://localhost:8888/restApi/index.php/sample/example/format/json
は本当に正常に動作し、この出力を与えるURLにアクセスし、自分のWebブラウザを使用して、
require APPPATH.'/libraries/REST_Controller.php';
class Sample extends REST_Controller
{
function example_get()
{
$this->load->helper('arh');
$this->load->model('users');
$users_array = array();
$users = $this->users->get_all_users();
foreach($users as $user){
$new_array = array(
'id'=>$user->id ,
'name'=>$user->name,
'age'=>$user->age,
);
array_push($users_array, $new_array);
}
$data['users'] = $users_array;
if($data)
{
$this->response($data, 200);
}
}
function user_put()
{
$this->load->model('users');
$this->users->insertAUser();
$message = array('message' => 'ADDED!');
$this->response($message, 200);
}
}
:
私は私のコントローラを持っています私のアプリでRestKitによって。
問題はputメソッドで発生します。このURL:
http://localhost:8888/restApi/index.php/sample/user
いつも私にこのようなエラーを与える:
このXMLファイルは、それに関連するすべてのスタイル情報を持っているように見えていません。ドキュメントツリーを以下に示します。
<xml>
<status/>
<error>Unknown method.</error>
これは私のユーザーモデルの仕事は、なぜ私は何も挿入していない私の_put方法の周りで何
<?php
class Users extends CI_Model {
function __construct()
{
parent::__construct();
}
function get_all_users()
{
$this->load->database();
$query = $this->db->get('users');
return $query->result();
}
function insertAUser(){
$this->load->database();
$data = array('name'=> "Sample Name", 'age'=>"99");
$this->db->insert('users', $data);
}
}
?>
のですか? ありがとうございます!
私は本当に混乱しているので、iOSにタグを付けました。 http://stackoverflow.com/questions/10136971/rest-web-service-for-reskit – ruelluna