我成功发布数据如下:
NSMutableURLRequest *scriptrequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"myurl.com"]];
[scriptrequest setHTTPMethod:@"POST"];
NSString *sendData =[NSString stringWithFormat:@"ID=%@&action=List", ID, nil];
NSData *scriptdata = [sendData dataUsingEncoding:NSUTF8StringEncoding];
[scriptrequest setHTTPBody:scriptdata];
NSError *scripterr;
NSURLResponse *scriptresponse;
NSData *scriptResponseData = [NSURLConnection sendSynchronousRequest:scriptrequest returningResponse:&scriptresponse error:&scripterr];
我的问题是,是否可以将 GET 数据附加到同一调用?
最佳答案
GET 和 POST 是不同类型的 HTTP 请求。
GET 请求主要用于获取网页内容,而 POST 用于插入/更新一些内容。
所以最终单个 HTTP 请求只能是以下之一。
Http types include:
GET
HEAD
POST
PUT
DELETE
TRACE
OPTIONS
CONNECT
PATCH
维基百科的更多技术细节: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
关于iOS 在同一请求中发送 POST 和 GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27444028/