<?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>Emran Hasan&#039;s Blog &#187; application</title>
	<atom:link href="http://phpfour.com/blog/tag/application/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpfour.com/blog</link>
	<description>The everyday sharing of Emran Hasan on software development.</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:39:05 +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>Using Twitter for sending server downtime alert</title>
		<link>http://phpfour.com/blog/2009/03/php-twitter-server-monitoring-curl-tips-rest-api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-twitter-server-monitoring-curl-tips-rest-api</link>
		<comments>http://phpfour.com/blog/2009/03/php-twitter-server-monitoring-curl-tips-rest-api/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 16:53:22 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[quick]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=238</guid>
		<description><![CDATA[Today I&#8217;ve written this simple PHP script to alert me through Twitter whenever our company&#8217;s local server is down. The script is called by a cron every 5 mins in my central hosting. Without much babble, here goes the code (if you&#8217;re interested to know why I needed this, that&#8217;s at the bottom of the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve written this simple PHP script to alert me through <a href="http://twitter.com">Twitter</a> whenever our company&#8217;s local server is down. The script is called by a cron every 5 mins in my central hosting. Without much babble, here goes the code (if you&#8217;re interested to know why I needed this, that&#8217;s at the bottom of the post):</p>
<p>[sourcecode language='php']<br />
<?php</p>
<p>// Specify the target URL in your server<br />
$targetUrl  = 'http://YOUR_SERVER_URL';</p>
<p>// Specify what the response is from the server<br />
$targetText = 'Hello from Daredevil';</p>
<p>// We will be using cURL for fetching the content<br />
$ch = curl_init();</p>
<p>// Set the params<br />
curl_setopt($ch, CURLOPT_URL, $targetUrl);<br />
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);</p>
<p>// Get the response<br />
$response = curl_exec($ch);<br />
curl_close($ch);</p>
<p>// Are things in right place ?<br />
if ($response == $targetText) {<br />
    die('Site is up and running!');<br />
}</p>
<p>// Nope, so here are the sender's twitter info<br />
$username = 'SENDER_TWITTER_USERNAME';<br />
$password = 'SENDER_TWITTER_PASSWORD';</p>
<p>// Receiver's twitter username<br />
$receiver = 'RECEIVER_TWITTER_USERNAME';</p>
<p>// Alert message to send<br />
$message = 'Daredevil is not responding, please fix ASAP!';</p>
<p>// The Twitter API address (new direct message)<br />
$url = 'http://twitter.com/direct_messages/new.json';</p>
<p>// We will be using cURL for this<br />
$ch = curl_init();</p>
<p>// Set the params<br />
curl_setopt($ch, CURLOPT_URL, "$url");<br />
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($ch, CURLOPT_POST, 1);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$receiver&amp;text=$message");<br />
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");</p>
<p>// Send the request<br />
$response = curl_exec($ch);<br />
curl_close($ch);</p>
<p>// Success or failure<br />
if (!empty($response)) {<br />
    echo 'Recipient has been notified.';<br />
} else {<br />
    echo 'No response from twitter.';<br />
}</p>
<p>[/sourcecode]</p>
<p><strong>Why I needed this?</strong></p>
<p>Recently we have setup a server at our office for committing work to a local SVN repository and have the QA test our work whenever they are ready. We also have a staging server where we do SVN update from this repo. Now, for the last few days, I&#8217;ve found the local server to be off due to a few reasons &#8211; but every time I realized this at night when I am back home and can&#8217;t do anything to turn it on. So I thought about this Twitter alert which is sent to my cell phone immediately when the server goes offline.</p>
<p>Btw, if Twitter doesn&#8217;t send SMS to your country, don&#8217;t worry. Check out the excellent service at <a href="http://twe2.com/">Twe2</a> that I&#8217;ve been using for a couple days.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/03/php-twitter-server-monitoring-curl-tips-rest-api/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Launch of Right Brain Solution Ltd.&#039;s website!</title>
		<link>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=launch-of-right-brain-solution-ltds-website</link>
		<comments>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 19:46:56 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[company]]></category>
		<category><![CDATA[emran]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/2007/11/09/launch-of-right-brain-solution-ltds-website/</guid>
		<description><![CDATA[I would like to let you all know that we&#8217;ve just launched the new website of Right Brain Solution Ltd.. I would like to personally thank all our friends, families, associates, and well-wishers &#8211; for all their support and patience. Please have a look at the site and let us know your views, comments, ideas, [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://www.rightbrainsolution.com"><img src="http://www.rightbrainsolution.com/images/rbs_shot.png" title="Right Brain Solution Ltd." border="0" /></a></p>
<p>I would like to let you all know that we&#8217;ve just launched the new website of <a href="http://www.rightbrainsolution.com">Right Brain Solution Ltd.</a>. I would like to personally thank all our friends, families, associates, and well-wishers &#8211; for all their support and patience.</p>
<p>Please have a look at the site and let us know your views, comments, ideas, criticism &#8211; anything that you would like to share with us.</p>
<p>Thank you all!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: phpfour.com @ 2012-02-04 13:09:30 -->
