-(void)setFormData:(NSDictionary *)formData withRequest:(NSMutableURLRequest *)request{
static NSString * boundaryData = @"12436041281943726692693274280";
//设置请求体中内容
NSMutableString *bodyString = [[NSMutableString alloc]init];
for(inti=[[formDataallKeys]count]-1; i>=0; i--) {
NSString*key = [formDataallKeys][i];
NSString*value = [formDataallValues][i];
if([keyisEqualToString:@"accessToken"]) {
value = [valuesubstringToIndex:32];
}
[bodyStringappendFormat:@"-----------------------------%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n",boundaryData,key,value];
}
[bodyStringappendFormat:@"-----------------------------%@--\r\n", boundaryData];
NSMutableData *bodyData = [[NSMutableData alloc]initWithLength:0];
NSData*bodyStringData = [bodyStringdataUsingEncoding:NSUTF8StringEncoding];
[bodyDataappendData:bodyStringData];
NSString*contentLength = [NSStringstringWithFormat:@"%d",[bodyDatalength]];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=---------------------------%@", boundaryData];
[requestsetValue:contentTypeforHTTPHeaderField:@"Content-Type"];
[requestsetValue:contentLengthforHTTPHeaderField:@"Content-Length"];
[requestsetHTTPBody:bodyData];
[requestsetHTTPMethod:@"POST"];
}