title: Sending SMS via Twilio on ios?
body: <p>How can i <a href="https://www.twilio.com/docs/api/rest" rel="nofollow">send SMS through twilio</a>, i have tried already and doing following.</p>
  
  <pre><code>- (IBAction)sendButtonPressed:(id)sender 
   {
      NSLog(@"Sending request.");
  
      // Common constants
      NSString *kTwilioSID = delegate.sessionId;
      NSString *kTwilioSecret = delegate.twilioToken;
      NSString *kFromNumber = delegate.twlioNumber;
      NSString *kToNumber = @"+14126620408";
      NSString *kMessage = @"Hi there......";
  
      // Build request
      NSString *urlString = [NSString stringWithFormat:@"https://%@:%@@api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages", kTwilioSID, kTwilioSecret, kTwilioSID];
  
      NSURL *url = [NSURL URLWithString:urlString];
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
      [request setURL:url];
      [request setHTTPMethod:@"POST"];
  
      // Set up the body
      NSString *bodyString = [NSString stringWithFormat:@"From=%@&amp;To=%@&amp;Body=%@", kFromNumber, kToNumber, kMessage];
      NSData *data = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
      [request setHTTPBody:data];
      NSError *error;
      NSURLResponse *response;
      NSData *receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  
      // Handle the received data
      if (error) {
          NSLog(@"Error: %@", error);
      } else {
          NSString *receivedString = [[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding];
          NSLog(@"Request sent. %@", receivedString);
      }     
   }
  </code></pre>
  
  <p>and got error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.
  Please help to do this issue, or share with me any helping meterial. Thanks in Advance.</p>