<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Communities, open web and technologies by Bogomil Shopov &#187; Twilio</title>
	<atom:link href="http://talkweb.eu/t/twilio/feed" rel="self" type="application/rss+xml" />
	<link>http://talkweb.eu</link>
	<description></description>
	<lastBuildDate>Sun, 05 Feb 2012 13:10:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sending SMS messages via Twilio Rest API</title>
		<link>http://talkweb.eu/openweb/338</link>
		<comments>http://talkweb.eu/openweb/338#comments</comments>
		<pubDate>Fri, 30 Jul 2010 12:10:19 +0000</pubDate>
		<dc:creator>Bogo</dc:creator>
				<category><![CDATA[Open Technologies]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[Twilio]]></category>

		<guid isPermaLink="false">http://talkweb.eu/?p=338</guid>
		<description><![CDATA[I am looking at Twilio API right now for a project and I am surprised how easy is to handle voice and SMS messages. Here is an example, written by me: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [...]]]></description>
			<content:encoded><![CDATA[<p>I am looking at Twilio API right now for a project and I am surprised how easy is to handle voice and SMS messages. Here is an example, written by me:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//get this from twillio website</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;twilio.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Twillio_SMS
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$ApiVersion</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$AccountSid</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$AuthToken</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$smsServer</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ApiVersion</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;2008-08-01&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AccountSid</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Axxxxxxxxxxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get your own after trial registration on Twilio.com</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AuthToken</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;axxxxxxxxxxxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smsServer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwilioRestClient<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AccountSid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AuthToken</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sendSMS<span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span> <span style="color: #000088;">$whattosend</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smsServer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">request</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$this-&gt;ApiVersion</span>/Accounts/<span style="color: #006699; font-weight: bold;">$this-&gt;AccountSid</span>/SMS/Messages&quot;</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">&quot;To&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">&quot;From&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">&quot;Body&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$whattosend</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsError</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error: <span style="color: #006699; font-weight: bold;">{$response-&gt;ErrorMessage}</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Done&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ApiVersion</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AccountSid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AuthToken</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$s</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Twillio_SMS<span style="color: #339933;">;</span>
<span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sendSMS</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4155992671'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'4155992671'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'this is a test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>GitHub</strong><br />
If you are interested in this topic, or if you have some ideas, please join me at <a href="http://github.com/bogomil/Code-samples/">my test repo @ Github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://talkweb.eu/openweb/338/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

