本文为您提供了Objective-C语言版本的提交查询接口对接DEMO示例
#import <Foundation/Foundation.h>
// 简单的HTTP POST请求示例
void sendSimplePostRequest() {
// 创建URL
NSURL *url = [NSURL URLWithString:@"https://api.ihuyi.com/idcard/entcert/Submit.json"];
// 创建请求
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
// 准备表单数据
NSString *postString = @"account=xxxxxxxx&password=xxxxxxxxx&ent_name=上海************有限公司&ent_code=913******&organization_code=403925******®_no=403925******&license_name_list=1&have_history=1&page_index=1&page_size=50&time=1623643787&";
NSData *postData = [postString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
// 发送请求
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"错误: %@", error.localizedDescription);
return;
}
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"响应: %@", responseString);
}];
[task resume];
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"发送请求...");
sendSimplePostRequest();
// 等待请求完成
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]];
}
return 0;
}
在线咨询
150,000家
企业客户
21年
行业经验
2V1
2对1客户支持