I'm using an SMS gateway which uses HTTP. I created a request using tutorials and questions on stackoverflow etc. but there's something wrong. When I enter the URL manually I can use the gateway without any problems but I cannot do it programmatically so I thought probably my code is not right. Appreciate any help!
NSString *post = [NSString stringWithFormat:@"user=%@&password=%@&api_id=%@&to=%@&text=%@",_username,_password,_apiID,[_numbers componentsJoinedByString:@","],_txtMsg.text];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://api.mySmsGateWay.com/http/sendmsg"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *responseCode = nil;
NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseCode error:&error];
if([responseCode statusCode] != 200){
NSLog(@"Error getting, HTTP status code %i", [responseCode statusCode]);
}
NSLog (@"%@", [[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding]);