ASIFormDataRequestを使用して、URL、タイトル、および要約の3つの値を投稿しています。それらはすべてシミュレータでは正常に動作しますが、デバイスでは動作しません。これが私が使用しているコードです:
- (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];
}
誰でも助けてくれます!