我想向服务器发送一条HTTP-POST消息。我在互联网上搜索过,那里只有非常老的帖子。THis是最好的一个:Simple http post example in Objective-C?
这个还能用吗?或者有没有新的方法来制作HTTP-POST消息?
发布于 2014-06-26 18:18:54
您应该使用AFNetworking库:https://github.com/AFNetworking/AFNetworking
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];发布于 2014-06-26 18:19:04
对于HTTP-POST通信来说,ASIHTTP Request无疑是一种很好的方式。这可能也是最容易使用的……
发布于 2014-06-26 18:19:20
下面是用于发出GET、简单POST和多部分POST请求的another tutorial。
查找"URL编码的HTTP POST请求“:)
https://stackoverflow.com/questions/24427716
复制相似问题