<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: How to send text messages using the Twilio API on Mac OS X and iPhone</title>
	<atom:link href="http://fredandrandall.com/blog/2011/10/05/how-to-send-text-messages-using-the-twilio-api-on-mac-os-x-and-iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://fredandrandall.com/blog/2011/10/05/how-to-send-text-messages-using-the-twilio-api-on-mac-os-x-and-iphone/</link>
	<description>Bloggin&#039; about whatever</description>
	<lastBuildDate>Mon, 30 Dec 2013 16:52:39 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>By: Mark Uppaluri</title>
		<link>http://fredandrandall.com/blog/2011/10/05/how-to-send-text-messages-using-the-twilio-api-on-mac-os-x-and-iphone/comment-page-1/#comment-19508</link>
		<dc:creator><![CDATA[Mark Uppaluri]]></dc:creator>
		<pubDate>Wed, 05 Sep 2012 16:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=613#comment-19508</guid>
		<description><![CDATA[Elegant implementation. I made minor changes to leverage NSJSONSerializer (iOS5+). Thanks.

//
//  Twilinator.m
//  Twilio
//
//  Created by Randall Brown on 10/4/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//  Added To 2012 by Mark Uppaluri
//

#import &quot;Twilinator.h&quot;
#import &quot;ASIFormDataRequest.h&quot;

@implementation Twilinator

- (id)initWithSID:(NSString*)sid authToken:(NSString*)theAuthToken fromNumber:(NSString*)number
{
    self = [super init];
    if (self) {
       accountSID = [sid retain];
       authToken = [theAuthToken retain];
       fromNumber = [number retain];
    }
    
    return self;
   
   
}

-(void)dealloc
{
    [accountSID release];
    [authToken release];
    [fromNumber release];
    [super dealloc];
}

-(void)sendTextMessage:(NSString*)textToSend toPhoneNumber:(NSString*)phoneNumber completionHandler:(void (^)(NSDictionary *responseDictionary, NSError *error))handler;
{
   __block ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@&quot;https://api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages.json&quot;, accountSID]]] autorelease];
   
   [request setUsername:accountSID];
   [request setPassword:authToken];
   
   [request addPostValue:fromNumber forKey:@&quot;From&quot;];
   [request addPostValue:phoneNumber forKey:@&quot;To&quot;];
   [request addPostValue:textToSend forKey:@&quot;Body&quot;];
   
   [request setCompletionBlock:^(){
       NSData *response = [request.responseString dataUsingEncoding:NSUTF8StringEncoding];
       NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:response options:0 error:nil];
       handler( responseDict, nil );
      
   }];
   
   [request setFailedBlock:^(){
      handler( nil, request.error );
   }];
   
   [request startAsynchronous];
}



@end]]></description>
		<content:encoded><![CDATA[<p>Elegant implementation. I made minor changes to leverage NSJSONSerializer (iOS5+). Thanks.</p>
<p>//<br />
//  Twilinator.m<br />
//  Twilio<br />
//<br />
//  Created by Randall Brown on 10/4/11.<br />
//  Copyright 2011 __MyCompanyName__. All rights reserved.<br />
//  Added To 2012 by Mark Uppaluri<br />
//</p>
<p>#import &#8220;Twilinator.h&#8221;<br />
#import &#8220;ASIFormDataRequest.h&#8221;</p>
<p>@implementation Twilinator</p>
<p>&#8211; (id)initWithSID:(NSString*)sid authToken:(NSString*)theAuthToken fromNumber:(NSString*)number<br />
{<br />
    self = [super init];<br />
    if (self) {<br />
       accountSID = [sid retain];<br />
       authToken = [theAuthToken retain];<br />
       fromNumber = [number retain];<br />
    }</p>
<p>    return self;</p>
<p>}</p>
<p>-(void)dealloc<br />
{<br />
    [accountSID release];<br />
    [authToken release];<br />
    [fromNumber release];<br />
    [super dealloc];<br />
}</p>
<p>-(void)sendTextMessage:(NSString*)textToSend toPhoneNumber:(NSString*)phoneNumber completionHandler:(void (^)(NSDictionary *responseDictionary, NSError *error))handler;<br />
{<br />
   __block ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@&#8221;https://api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages.json&#8221;, accountSID]]] autorelease];</p>
<p>   [request setUsername:accountSID];<br />
   [request setPassword:authToken];</p>
<p>   [request addPostValue:fromNumber forKey:@&#8221;From&#8221;];<br />
   [request addPostValue:phoneNumber forKey:@&#8221;To&#8221;];<br />
   [request addPostValue:textToSend forKey:@&#8221;Body&#8221;];</p>
<p>   [request setCompletionBlock:^(){<br />
       NSData *response = [request.responseString dataUsingEncoding:NSUTF8StringEncoding];<br />
       NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:response options:0 error:nil];<br />
       handler( responseDict, nil );</p>
<p>   }];</p>
<p>   [request setFailedBlock:^(){<br />
      handler( nil, request.error );<br />
   }];</p>
<p>   [request startAsynchronous];<br />
}</p>
<p>@end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
