我正在使用 ASIFormDataRequest 发布三个值,即 url、标题和摘要。所有这些都在模拟器上运行良好,但在设备上不起作用。这是我正在使用的代码:
- (IBAction)addLinkPressed:(UIButton *)sender {
ASIFormDataRequest *loginRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://MyWebsite.com/login.php"]];
[loginRequest setRequestMethod:@"POST"];
[loginRequest setPostValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"defaultUsername"] forKey:@"username"];
[loginRequest setPostValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"defaultPassword"] forKey:@"password"];
[loginRequest setUseKeychainPersistence:YES];
[loginRequest setDelegate:self];
[loginRequest setDidFinishSelector:@selector(requestLoginFinished:)];
[loginRequest setDidFailSelector:@selector(requestLoginFailed:)];
[loginRequest startSynchronous];
NSString *strURL = @"http://MyWebsite.com/send_link.php";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
[request setDelegate:self];
[request setPostValue:self.linkField.text forKey:@"url"];
[request setPostValue:self.linkTitleField.text forKey:@"title"];
[request setPostValue:self.linkSummaryField.text forKey:@"summary"];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[request startAsynchronous];
}
任何人都可以帮助我!