将CURL请求转换为AFNetworking请求

时间:2014-04-14 06:49:09

标签: objective-c curl afnetworking afnetworking-2

我想在AFNetworking 2.0中使用以下curl请求。有什么想法我会怎么做?

curl --request POST -d "login=remitest&password=password&api_version=3" https://8tracks.com/sessions.json

1 个答案:

答案 0 :(得分:2)

试试这个:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"remitest", @"login",
                        @"password", @"password",
                        @3, @"api_version",
                        nil];
[manager POST:@"https://8tracks.com/sessions.json" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do your stuff
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    // fail cases
}];

希望有所帮助