当我登录并通过我的iphone应用程序上的ASI HTTP请求库发布评论时,我一直遇到这个问题。它要么我的登录没有成功保存,我没有发送用户名和密码到服务器登录我发布评论或审查POST方法是错误的...如果有人可以帮助我会非常感谢它,因为我我已经把头撞了几个月。
登录方式
- (IBAction)LoginButton:(id)sender
{
NSURL *wsURL = [NSURL URLWithString:@"https://furious-ice-356.heroku.com/login_check.xml"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:wsURL];
[request setRequestMethod:@"GET"];
[request setUseKeychainPersistence:YES];
request.shouldPresentCredentialsBeforeChallenge = YES;
[request addBasicAuthenticationHeaderWithUsername:self.username.text andPassword:self.password.text];
//[request setUsername:self.username.text];
// [request setPassword:self.password.text];
[request setDelegate:self];
[request startAsynchronous];
self.Login = YES;
self.SubmitBool = NO;
}
查看帖子方法
-(void)Submit
{
NSURL *url = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://furious-ice-356.heroku.com/places/%@/reviews.xml",self.identifier]]];
self.bestnight.text = @"Monday";
ASIFormDataRequest *request1 = [ASIFormDataRequest requestWithURL:url];
[request1 setUsername:self.username];
[request1 setPassword:self.password];
//[request1 setValidatesSecureCertificate:NO];
//[request1 setShouldPresentCredentialsBeforeChallenge:NO];
[request1 setRequestMethod:@"POST"];
[request1 setPostValue:self.bestnight.text forKey:@"review[best-night]"];
[request1 setPostValue:self.comments.text forKey:@"review[comments]"];
[request1 setPostValue:self.StarRating.text forKey:@"review[rating]"];
[request1 setDelegate:self];
[request1 startAsynchronous];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
我可以在网络服务上添加评论等,但我似乎无法通过asi请求进行评论。
提前致谢