Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing invalid phone number when I call the API through objective C #58

Closed
ppatel03 opened this issue Dec 4, 2015 · 3 comments
Closed

Comments

@ppatel03
Copy link

ppatel03 commented Dec 4, 2015

NSString* query = @"{\"number\":3154478103,\"message\":\"Test\"}";

NSLog(@"SMS send request Query : %@",query);
NSString *post = [NSString stringWithFormat:@"%@",query];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding ];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *url = @"http://textbelt.com/text/";

[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:METHOD_POST];
[request setHTTPBody:postData];

NSLog(@"Sending the SMS to the user ");

//creating the session to get the json response
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[session dataTaskWithRequest:request  completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

    NSString* jsonResponse = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    NSLog(@"This is Asynchronous Response : %@",jsonResponse);

}] resume];
@typpo
Copy link
Owner

typpo commented Dec 4, 2015

You need to POST this as normal HTTP parameters, not a JSON object. The POST body should probably look like number=XXXX&message=Test.

@typpo typpo closed this as completed Dec 4, 2015
@typpo
Copy link
Owner

typpo commented Dec 4, 2015

Possibly related as well is issue #45

@ppatel03
Copy link
Author

ppatel03 commented Dec 5, 2015

Thank you so much !!! It worked !!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants