0
以下参数我想我的要求看,并在铁轨服务器这样的效果:我想知道如何登录到一个轨道3服务器通过iphone
Started POST "https://stackoverflow.com/users/sign_in" for 127.0.0.1 at 2011-08-21 16:22:09
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"mBzfQ73jtZ9rlj01+RCSs6mJoViFQZuRbwunQiX57oU=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
(0.4ms) UPDATE "users" SET "last_sign_in_at" = '2011-08-21 23:18:50.886178', "current_sign_in_at" = '2011-08-21 23:22:09.698853', "sign_in_count" = 7, "updated_at" = '2011-08-21 23:22:09.699635' WHERE "users"."id" = 1
Redirected to http://localhost:3000/user
Completed 302 Found in 206ms
但我的要求看起来是这样的:
Started POST "https://stackoverflow.com/users/sign_in" for 127.0.0.1 at 2011-08-21 16:19:56
Processing by Devise::SessionsController#create as HTML
Parameters: {"commit"=>"Sign in", "password"=>"[FILTERED]", "email"=>"[email protected]", "remember_me"=>"1", "session"=>{"commit"=>"Sign in", "password"=>"[FILTERED]", "email"=>"[email protected]", "remember_me"=>"1", "action"=>"create", "controller"=>"devise/sessions"}}
WARNING: Can't verify CSRF token authenticity
Completed in 1ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"commit"=>"Sign in", "password"=>"[FILTERED]", "email"=>"[email protected]", "remember_me"=>"1", "session"=>{"commit"=>"Sign in", "password"=>"[FILTERED]", "email"=>"[email protected]", "remember_me"=>"1"}}
WARNING: Can't verify CSRF token authenticity
Rendered /Users/hdj/.rvm/gems/[email protected]/gems/devise-1.4.2/app/views/devise/shared/_links.erb (1.6ms)
Rendered /Users/hdj/.rvm/gems/[email protected]/gems/devise-1.4.2/app/views/devise/sessions/new.html.erb within layouts/application (25.4ms)
Completed 200 OK in 162ms (Views: 94.0ms | ActiveRecord: 0.9ms)
这我确定犯规登录我使用可可OBJ C代码的IM是这样的:
NSString *urlString = @"http://localhost:3000/users/sign_in";
NSDictionary *thestuff = [NSDictionary dictionaryWithObjectsAndKeys:
@"[email protected]", @"email",
@"123456", @"password",
@"1",@"remember_me",
@"Sign in", @"commit",nil];
NSString *tojson = [thestuff JSONRepresentation];
//NSLog(@"%@ %@", thestuff, tojson);
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlString]];
[request appendPostData:[tojson dataUsingEncoding:NSUTF8StringEncoding]];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request startSynchronous];
即时通讯使用同步只是因为我需要用户登录之前我移动到下一个视图。另一件事是,我不确定如何从请求中看到如何发送标题为电子邮件和密码的用户名和密码。所以即时通讯使用JSON格式。 本质上我想知道如何改变这段代码以获得所需的结果。另外,有没有办法以HTML格式发送数据,而不是像我在这里使用的那样使用json? 我真的很感谢这里的帮助,如果你需要更多的代码,我很乐意提供它。