0
を購入して私はAFNewtorkingを使用していますが、APIのため 下にSMSを送信することができる午前 与える悪い要求400.By使用して試行回数または送信SMSメッセージは、私は数を購入したが、私は、SMSメッセージを送信することはできませんよ数
NSString *kTwilioSID = @" ";
NSString *kTwilioSecret = @" ";
NSString *kFromNumber = @"+ ";
NSString* nospacestring =[phno stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *kToNumber = nospacestring;
NSString *kSMSMessage = @"Smart Child Info is a precautionary app designed to fight child abduction, exploitation, and maltreatment.";
// Build request
NSString *urlString = [NSString stringWithFormat:@"https://%@:%@@api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages/", kTwilioSID, kTwilioSecret, kTwilioSID];
NSString *Loginurl = urlString;
NSDictionary*
[email protected]{@"From":kFromNumber,@"To":kToNumber,@"Body":kSMSMessage};
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/plain",@"application/xml",nil];
[manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[manager POST:Loginurl parameters:dic progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"Response from server : %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]);
NSData * data = (NSData *)responseObject;
NSString* xmlData = [NSString stringWithCString:[data bytes] encoding:NSISOLatin1StringEncoding];
NSLog(@"%@",xmlData);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Success" message:@"Message has been sent" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}
failure:^(NSURLSessionTask *operation, NSError *error)
{
NSLog(@"Error: %@", error);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Failed" message:@"Message not sent" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}];