在iphone开发中的get请求和post请求

若您的请求为get方式,则使用ASIHTTPRequest类来实现您的需求。

如:ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:reqURL];
    request.tag = REQTYPE_GET_RECOMMENDDETAIL;
    request.timeOutSeconds = 30;
    [request setDelegate:self];
    [request startAsynchronous];

若您的请求方式为post方式,则使用ASIFormDataRequest类来实现您的需求。

如:- (void) getFileUploadInfo:(NSString*)reqURL
                      fileSize:(int)fileSize
                        ftitle:(NSString*)ftitle
               
{
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:reqURL]];
    request.tag = REQTYPE_GET_MYSPACEFILETRANSPORTRINFO;
    request.timeOutSeconds = 30;
    [request setDelegate:self];
    [request setPostValue:[NSNumber numberWithInt:fileSize] forKey:@"fileSize"];
    [request setPostValue:ftitle forKey:@"title1"];
    [request startAsynchronous];
}

posted @ 2012-08-14 11:13  _安静ゝ  阅读(688)  评论(0编辑  收藏  举报