2013-12-01 3 views
0
NSURL *url = [NSURL URLWithString:@"http://test.com/misc/app/ws/ws_user_registration.php?"]; 
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; 

    [request setRequestMethod:@"POST"]; 
    [request setDelegate:self]; 

    [request appendPostData:[[NSString stringWithFormat:@"{\"user_name\":\"%@\",\"user_tag_status\":\"%@\",\"description\":\"%@\",\"mobile_number\":\"%@\",\"device_type\":\"%@\",\"device_id\":\"%@\",\"device_token\":\"%@\",\"os\":\"%@\",\"os_version\":\"%@\",\"image_data\":\"%@\",\"user_id\":\"%@\"}",self.phnNumTxtFld.text,@"live",@"description",self.phnNumTxtFld.text,@"iPhone",appDelegate.deviceID,appDelegate.deviceToken,@"iOS",[UIDevice currentDevice].systemVersion,[data base64EncodedString],@""] dataUsingEncoding:NSUTF8StringEncoding]]; 
    [request setDidFinishSelector:@selector(getTreeRequestFinished:)]; 
    [request setDidFailSelector:@selector(getTreeRequestFailed:)]; 
    [request startAsynchronous]; 

appendPostData: передача NSData, но сервер не получает эти данные.ASIHttpRequest не передает данные

ответ

0

Чтобы разместить данные использовать ASIFormDataRequest

NSURL *url = [NSURL URLWithString:@"http://test.com/misc/app/ws/ws_user_registration.php?"]; 

ASIFormDataRequest* asiRequest = [ASIFormDataRequest requestWithURL: url]; 
[asiRequest setPostFormat:ASIMultipartFormDataPostFormat]; 
[asiRequest addData:DATA_TO_SEND withFileName:FILE_NAME andContentType:FILE_CONTENT_TYPE forKey:YOUR_FILE_UPLOADKEY; 

[asiRequest setDidFinishSelector:@selector(connectionFinishedLoading:)];// called when connection successfully got finished and recieve resoponse 
[asiRequest setDidFailSelector:@selector(requestWentWrong:)]; // called when connection went wrong due to bad url connection or timeout, etc. 

[asiRequest setDelegate:self]; 
[asiRequest startAsynchronous]; 

Для получения дополнительной информации читать asihttp docs

+0

Спасибо за помощь я решил с этим [asiRequest addPostValue: @ "Бен" forKey: @ "имена"]; :) – DipakSonara

Смежные вопросы