<?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>Mike Hillyer&#039;s Personal Webspace &#187; PHP</title>
	<atom:link href="http://mikehillyer.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikehillyer.com</link>
	<description>Gentlemen! Look, and Behold!</description>
	<lastBuildDate>Wed, 21 Sep 2011 20:45:02 +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>Twilio: Rolling My Wife&#8217;s Eyes in 31 Lines of PHP</title>
		<link>http://mikehillyer.com/reviews/twilio-rolling-my-wifes-eyes-in-31-lines-of-php/</link>
		<comments>http://mikehillyer.com/reviews/twilio-rolling-my-wifes-eyes-in-31-lines-of-php/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 02:19:29 +0000</pubDate>
		<dc:creator>Mike Hillyer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[telephone]]></category>
		<category><![CDATA[twilio]]></category>

		<guid isPermaLink="false">http://mikehillyer.com/?p=49</guid>
		<description><![CDATA[For some reason a certain number of my little side projects result in "The Look", that rolled-eyes expression that let's me know I'm such a nerd. Given that Valentine's Day fell on a weekend this year and I had a little free time this Sunday morning, the look was inevitable. Today I finally had a [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_50" class="wp-caption alignright" style="width: 250px"><img class="size-full wp-image-50" title="Rolled Eyes" src="http://mikehillyer.com/media//2811214632_85ff0c3f5a_m.jpg" alt="And then she gives you that look" width="240" height="160" /><p class="wp-caption-text">The Look - Flickr user Nabo, used under CC license</p></div>
<p>For some reason a certain number of my little side projects result in "The Look", that rolled-eyes expression that let's me know I'm such a nerd. Given that Valentine's Day fell on a weekend this year and I had a little free time this Sunday morning, the look was inevitable.</p>
<p>Today I finally had a few minutes to try out <a title="Twilio Homepage" href="http://www.twilio.com" target="_blank">Twilio</a>, a new web services provider that helps to telephone-enable applications through an easy REST API. In the case of PHP it is made even easier through a helper library provided by Twilio on their developer site.</p>
<p>Twilio is free to sign up and they provide a generous starting credit to begin exploring their service in a sandbox environment (they let you use their sandbox number for incoming call tests and put a watermark message on the front of all your outgoing communications). You can send and receive calls, add interactive menus to the calls, use recorded voice clips or text-to-speech and even send and receive text messages, all through their APIs and XML formatted speech scripts.</p>
<p>My Hello World test for the morning was simple; I wanted to call my home number and deliver a Valentine's Day greeting. To do so I first signed up with Twilio, then went to my Twilio dashboard for my API key and to download the twilio.php helper library.</p>
<p>I then created helloworld.php with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</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: #666666; font-style: italic;">/* Twilio REST API version */</span>
<span style="color: #000088;">$ApiVersion</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;2008-08-01&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Set our AccountSid and AuthToken */</span>
<span style="color: #000088;">$AccountSid</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ACxxxxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$AuthToken</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Outgoing Caller ID you have previously validated with Twilio */</span>
<span style="color: #000088;">$CallerID</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'2223334444'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Instantiate a new Twilio Rest Client */</span>
<span style="color: #000088;">$client</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;">$AccountSid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$AuthToken</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* make Twilio REST request to initiate outgoing call */</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</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;">$ApiVersion</span>/Accounts/<span style="color: #006699; font-weight: bold;">$AccountSid</span>/Calls&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;Caller&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$CallerID</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">&quot;Called&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'4445556666'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">&quot;Url&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;http://mysite.com/helloworld.xml&quot;</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;Started call: <span style="color: #006699; font-weight: bold;">{$response-&gt;ResponseXml-&gt;Call-&gt;Sid}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Initiating a call just requires a number to "call from" (in reality it's just the number the Twilio system presents as caller ID), a number to call to, and the Account ID and token. The URL specified in the request to call out is an XML document that defines what happens during the call, using a format referred to as <a href="http://www.twilio.com/docs/api/2008-08-01/twiml/">TwiML</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Response<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Say<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Happy Valentine's Day!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Say<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Response<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In this case things are pretty straightforward, the system also has the ability to play mp3 files, take responses and branch based on keypresses and perform a number of additional actions. It looks like one could easily build a menu system or a survey system.</p>
<p>All in all an interesting offering that I'll be tinkering with more in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikehillyer.com/reviews/twilio-rolling-my-wifes-eyes-in-31-lines-of-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resolving PHP-MySQL Connection Issues</title>
		<link>http://mikehillyer.com/php/resolving-php-mysql-connection-issues/</link>
		<comments>http://mikehillyer.com/php/resolving-php-mysql-connection-issues/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 16:11:11 +0000</pubDate>
		<dc:creator>Mike Hillyer</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SELinux]]></category>

		<guid isPermaLink="false">http://mikehillyer.com/?p=19</guid>
		<description><![CDATA[I ran into an interesting issue when installing WordPress on my re-installed server, I could not get a database connection during installation. I added some debugging and discovered that I had a "Can't connect to MySQL server on" error returned after the call to mysql_connect() in PHP. To check the source of the issue I [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an interesting issue when installing WordPress on my re-installed server, I could not get a database connection during installation. I added some debugging and discovered that I had a "Can't connect to MySQL server on" error returned after the call to mysql_connect() in PHP.</p>
<p>To check the source of the issue I then tried to connect on the command-line using the mysql client, which occurred successfully, confirming that I was using the correct credentials and host address (this was a remote MySQL server).</p>
<p>I next created a test PHP script with a simple mysql_connect() call, and executed it with "php test.php" from the command-line, which was also successful.</p>
<p>Finally I accessed test.php through a browser, where again the connection failed.</p>
<p>So I was dealing with a situation where it was Apache in particular that was unable to connect to the remote MySQL server. Thanks to <a title="Wez Furlong's Blog" href="http://netevil.org" target="_blank">Wez Furlong</a>'s ideas I was able to narrow this down to SELinux blocking outgoing communications by Apache.</p>
<p>So, if you're having issues with Apache and specifically connecting out, you may want to <a title="Disable SELinux for Apache" href="http://www.cyberciti.biz/faq/howto-disable-httpd-selinux-security-protection/" target="_blank">disable SELinux for Apache</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikehillyer.com/php/resolving-php-mysql-connection-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

