我正在首次使用AFNetworking庫,並且我已經成功實現了json解析並且工作完美,現在我需要創建一個註冊頁面,其中用戶將填寫所有的細節,如用戶名,密碼,問題,答案,名稱,它會將所有數據發佈到Web服務器上。我已經嘗試過幾個例子,但是它沒有在web服務器上發佈。如何使用iPhone中的AFNetWorking在Web服務器上發佈數據
下面是Web服務器
NSURL *baseURL = [NSURL URLWithString:@"http://apollowebservice.10summer.com/registration.php"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[httpClient defaultValueForHeader:@"Accept"];
NSMutableDictionary *requestArray = [NSMutableDictionary new];
[requestArray setObject: @"Kashif"
forKey: @"user_name"];
[requestArray setObject: @"[email protected]"
forKey: @"user_email"];
[requestArray setObject:@"[email protected]" forKey:@"user_password"];
[requestArray setObject:@"What is your name" forKey:@"user_question"];
[requestArray setObject:@"Kashif Answer" forKey:@"user_answer"];
[httpClient postPath:@"method" parameters:requestArray success:^(AFHTTPRequestOperation *operation, id responseObject) {
// reponseObject will hold the data returned by the server.
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error retrieving data: %@", error);
}];
提供你如何努力的例子,沒有這個。 – hakonbogen
我編輯了我的問題。 – Kashif
錯誤中寫了什麼? – hakonbogen