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? 我真的很感謝這裏的幫助,如果你需要更多的代碼,我很樂意提供它。