below i've shared some PHP code, Iam struck in the passing the custom headers and creating the $message and $header in objective-c. so please help me out in this.
enter image description here
Asked
Active
Viewed 52 times
0

user3402362
- 13
- 4
1 Answers
0
According to your image
POST for posting data to SERVER
-(void)postDataToServer
{
//STEP 1 :Create the MutableURL Request
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.rgsgapp.com/api/debug/show"]];
//STEP 2 :create the Method "POST"
[request setHTTPMethod:@"POST"];
//STEP 3 :Pass The String to server(YOU SHOULD GIVE YOUR PARAMETERS INSTEAD OF MY PARAMETERS)
NSString *userUpdate =[NSString strin gWithFormat:@"API-ID=%@&API-TIME=%@API-HASH=%@",txtFldID.text,txtFldTime.text,txtFldHash.text,nil]; //Here you can give string or textField value
//STEP 4 :Check The Value what we passed
NSLog(@"the data Details is =%@", userUpdate);
//STEP 5 :Convert the String to Data
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
//STEP 6 :Apply the data to the body
[request setHTTPBody:data1];
//STEP 7 :Create the response and Error
NSError *err;
NSURLResponse *response;
//STEP 8 :send synchronous request to server
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
//STEP 9 :getting the response
NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];
//STEP 10:Check whether we got the Response or Not
NSLog(@"got response==%@", resSrt);
if(resSrt)
{
NSLog(@"got response");
}
else
{
NSLog(@"faield to connect");
}
}
Call this above method in your action method or where you want to do.

user3182143
- 9,459
- 3
- 32
- 39
-
Please tick my answer because it helpful for others,if they see your question. – user3182143 Nov 20 '15 at 12:39
-
Above this is the very basic synchronous method for posting data to server. – user3182143 Nov 20 '15 at 12:46
-
Okey I will help you.What did you understand from above my answer? – user3182143 Nov 20 '15 at 12:51
-
http://stackoverflow.com/questions/33364156/how-to-post-uitextfield-data-in-web-service-on-unbutton/33365242#33365242 – user3182143 Nov 20 '15 at 12:56
-
Kindly step by step go through my answer. – user3182143 Nov 20 '15 at 13:21
-
Especially this line - NSString *userUpdate =[NSString strin gWithFormat:@"API-ID=%@&API-TIME=%@API-HASH=%@",txtFldID.text,txtFldTime.text,txtFldHash.text,nil]; //Here you can give string or textField value – user3182143 Nov 20 '15 at 13:22
-
But in your image it shows,3 parameters API-ID,API-TIME,API-HASH – user3182143 Nov 20 '15 at 13:36
-
see if you give three parameters with url after that it is not possible to send another parameter with url. – user3182143 Nov 20 '15 at 14:03