我试图在php中发布一个使用usercake生成的工作登记表,并且当按下按钮时,我试图向注册文件发出一个post请求。但是什么都没发生。我想我说错了什么。这是我目前的密码。
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://thissite.co/"]];
[httpClient setParameterEncoding:AFFormURLParameterEncoding];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST"
path:@"http://thissite.co/cake/register.php?"
parameters:@{@"username":@"testingService", @"displayname":@"testingService", @"password":@"thisismypassword", @"passwordc":@"thisismypassword", @"email":@"testingservice@service.com", @"bio":@"I am this amazing bio", @"skills":@"hackingthissuckerfromaframework", @"interests":@"I like to hack", @"skills_needed":@"php anyone", @"company":@"Noneofyourtesting", @"dob":@"nopeeeee", @"occupation":@"noob"}];
}发布于 2014-01-19 19:37:05
看起来您没有执行您创建的请求。尝试在方法的末尾添加此代码。
AFHTTPRequestOperation * httpOperation = [httpClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
//success code
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//error handler
}];
[httpClient enqueueHTTPRequestOperation:httpOperation];或者有更简单的方法
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://thissite.co/"]];
[httpClient setParameterEncoding:AFFormURLParameterEncoding];
[httpClient postPath:@"cake/register.php" parameters:@{@"username":@"testingService", ...} success:^(AFHTTPRequestOperation *operation, id responseObject) {
//success code
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//error handler
}];https://stackoverflow.com/questions/21220390
复制相似问题