gpt4 book ai didi

ios - AFNetworking如何发送一串post请求?

转载 作者:行者123 更新时间:2023-11-29 02:07:23 25 4
gpt4 key购买 nike

AFNetworking如何发送一串post请求?

//restrinBASE64STRING is a NSString ,Program error
[manager POST:URLString parameters:restrinBASE64STRING success:^(AFHTTPRequestOperation *operation, id responseObject) {

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];

最佳答案

解决问题

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:URLString]];
[request setHTTPMethod:@"POST"];
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[restrinBASE64STRING dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postBody];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];

operation.responseSerializer = [AFHTTPResponseSerializer serializer];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];
[[NSOperationQueue mainQueue] addOperation:operation];

关于ios - AFNetworking如何发送一串post请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29640293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com