我的问题是:如何使用ASIFormDataRequest
和第二个创建与下面相同的请求,因为我认为我需要从响应中解析 JSON。
http://exampledomain.com/mobile_api/register/?client=iphone&info=A=iPhone/OS=5.1/C=UA&time=1342780143&udid=8b6f0cc104d137ae2e1730235f5664094b831122&version=1.0&secure=5444d72741bad93b916577d9297fa
现在我尝试使用这样的代码
NSString *strURL = @"http://test2.mafia.ua/mobile_api/register/";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
[request setDelegate:self];
[request setPostValue:@"iphone" forKey:@"client"];
[request setPostValue:@"A=iPhone/OS=5.1/C=UA" forKey:@"info"];
[request setPostValue:@"1342780143" forKey:@"time"];
[request setPostValue:@"8b6f0cc104d137ae2e1730235f5664094b831122" forKey:@"udid"];
[request setPostValue:@"1.0" forKey:@"version"];
[request setPostValue:@"5444d72741bad93b916577d9297fa" forKey:@"secure"];
[request startAsynchronous];
它是否正确?
我也实现了委托方法
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"Response %d ==> %@", request.responseStatusCode, [request responseString]);
}
- (void)requestFailed:(ASIHTTPRequest *)request {
}
作为回应,如果我使用某些浏览器,我会得到这个(我认为这是 JSON)。
{“状态”:“确定”,“秘密”:“b82b7771f600772c2c5af903b117b5e”,“客户端”:“200004”,“过期”:“1345372850”}