企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ NSString *host = @"http://www.api51.cn"; NSString *path = @"/api/smsApi/send"; NSString *method = @"POST"; NSString *querys = @""; NSString *url = [NSString stringWithFormat:@"%@%@%@", host, path , querys]; NSString *bodys = @"mobile=13288888888&params=1024%2C%E5%BC%A0%E4%B8%89&sign=%E7%BD%91%E6%9E%81%E7%A7%91%E6%8A%80&token=token&tpl_id=46792"; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url] cachePolicy:1 timeoutInterval: 5]; request.HTTPMethod = method; [request addValue: @"application/x-www-form-urlencoded; charset=UTF-8" forHTTPHeaderField: @"Content-Type"]; NSData *data = [bodys dataUsingEncoding: NSUTF8StringEncoding]; [request setHTTPBody: data]; NSURLSession *requestSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; NSURLSessionDataTask *task = [requestSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable body , NSURLResponse * _Nullable response, NSError * _Nullable error) { NSLog(@"Response object: %@" , response); NSString *bodyString = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding]; //打印应答中的body NSLog(@"Response body: %@" , bodyString); }]; [task resume]; ~~~