我正在从 iphone 应用程序将数据发布到服务器,但是在读取有关“过度不良访问”的帖子行代码时出现异常。我用于发送四个变量数据的代码相同,然后如果我在帖子中添加更多变量,它会正常工作,它会给出错误.
NSString*category=titleCategory;
NSString*sub_Category=titleSubCategory;
NSString*content_Type=@"Audio";
content_Title=TitleTextField.text;
NSString*content_Title=content_Title;
NSString*publisher=@"Celeritas";
content_Description=descriptionTextField.text;
NSString*content_Description=content_Description;
NSString*content_ID=@"10";
NSString*content_Source=@"http://www.celeritas-solutions.com/pah_brd_v1/productivo/productivo/pro/ali.wav";
NSString *post =[[NSString alloc] initWithFormat:@"category=%@&sub_Category=%@&content_Type=%@&content_Title=%@&publisher=%@&content_Description=%@&content_ID=%@&content_Source=%@",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSURL *url=[NSURL URLWithString:@"http://www.celeritas-solutions.com/pah_brd_v1/productivo/addData.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);
下面是它破坏代码的行
NSString *post =[[NSString alloc] initWithFormat:@"category=%@&sub_Category=%@&content_Type=%@&content_Title=%@&publisher=%@&content_Description=%@&content_ID=%@&content_Source=%@",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];