【发布时间】:2014-06-26 10:08:04
【问题描述】:
我想向服务器发送一条 HTTP-POST 消息。我在互联网上搜索过,那里只有非常旧的帖子。这是最好的:Simple http post example in Objective-C?
这仍然有效吗?还是有新的方法来制作 HTTP-POST 消息?
【问题讨论】:
标签: ios objective-c xcode http-post
我想向服务器发送一条 HTTP-POST 消息。我在互联网上搜索过,那里只有非常旧的帖子。这是最好的:Simple http post example in Objective-C?
这仍然有效吗?还是有新的方法来制作 HTTP-POST 消息?
【问题讨论】:
标签: ios objective-c xcode http-post
您应该使用 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);
}];
【讨论】:
ASIHTTP Request 无疑是一种很好的 HTTP-POST 通信方式。这可能也是最容易使用的......
【讨论】:
这里是 another tutorial,用于发出 GET、简单 POST 和多部分 POST 请求。
查找“URL 编码的 HTTP POST 请求”:)
【讨论】: