2012-06-07 52 views
0

我想從我的iPhone應用程序獲得聯繫表格。我在服務器上有一個contact.php腳本,我需要將數據從我的應用程序傳遞到服務器。我被告知使用ASIHTTPRequest框架,但我需要幫助將UITextField的值發送到服務器的代碼。任何幫助將不勝感激從iPhone應用程序聯繫表格

回答

0

OK算出來了。我爲連接到我的web服務器的ASIHTTPRequest框架,並稱爲sendForm行動

-(IBAction)sendForm:(id)sender { 

NSURL *url = [NSURL URLWithString:@"http://myurl/mail.php"]; 
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 
[request setPostValue:[name text] forKey:@"name"]; 
[request setPostValue:[email text] forKey:@"email"]; 

[request setDelegate:self]; 
[request startSynchronous]; 
} 
0

試試這個,ASIHTTPRequest

ASIHTTPRequest *_request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; 
[_request setDelegate:self]; 
[_request setRequestMethod:@"POST"]; 
NSMutableData *data = [[NSMutableData alloc] initWithData:[textField.text dataUsingEncoding:NSUTF8StringEncoding]]; 
[_request appendPostData:data]; 
[_request start]; 
[data release]; 

代表

- (void)requestFinished:(ASIHTTPRequest *)request 
+0

我可以只使用nsurl從我的文本字段的數據發佈到網址? – XpApp

0

檢查我的答案,例如,從先前的SO帖子。 Link

這裏描述了使用ASIHTTPRequest框架到POST變量到服務器端腳本。

希望這會有所幫助!

相關問題