此示例代碼應該可以幫助您
-(void)sendRequest
{
int userId=10, time=10000;
NSString *name = @"ABC";
float info = 1.0;
NSString *urlString = [NSString stringWithFormat:@"http://test.com/mobile_api/register?id=%d&name=%@&info=%f&time=%d",userId,name,info,time];
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
//You need to add ASIHTTPRequestDelegate in header(.h) file
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
// Use when fetching binary data
NSData *responseData = [request responseData];
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
}
在一個側面說明,如果你正在做一個RESTful API,你不應該做一個GET創建/寫服務器端。它應該是一個帖子,理想情況下與身體的數據。 – bryanmac 2012-07-20 12:57:34
很遺憾,'讓我谷歌爲你'鏈接被禁止在評論中... – akashivskyy 2012-07-20 12:59:51