<?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; curl</title>
	<atom:link href="http://phpfour.com/blog/tag/curl/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>Code Updates (HTTP class, Extended CodeIgniter Model, Cross-domain AJAX transport)</title>
		<link>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updated-http-class-extended-model-codeigniter-cross-domain-ajax-php</link>
		<comments>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:27:47 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[essential]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=186</guid>
		<description><![CDATA[Greetings to all the readers of my blog. Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings to all the readers of my blog.</p>
<p>Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to reassure you that the site is up and will be up as usual <img src='http://phpfour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Now, besides the slightly customized theme from Elegant Themes, I have put a few code updates. They are detailed below:</p>
<h3>Extended Model for CodeIgniter</h3>
<p>The <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original version</a> of the Extended Model for CodeIgniter has been serving many people well. Although most users loved the nifty functions of the Model, many (including me) didn&#8217;t like the hacking of CI core to get this functionality. With the release of CodeIgniter 1.7, we can avoid that as we can now overload the Model class of CI like the other libraries. Follow this instruction:</p>
<p>1. Download the updated version from <a href="http://www.phpfour.com/blog/downloads/model-ci-2">here</a><br />
2. Put it in your application/libraries folder<br />
3. In your model files, use it this way: <strong>class Product extends MY_Model</strong><br />
4. Everything else is same just like the <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original</a> one</p>
<h3>HTTP Class</h3>
<p>There is not much update in this class except for a few bug fixes (thanks to you guys). Also, I have included a license file in the package as many of you have asked. It&#8217;s released under the MIT license. The original post is <a href="http://www.phpfour.com/blog/2008/01/php-http-class/">here</a> for reference.</p>
<p>Download the update from <a href="http://www.phpfour.com/blog/downloads/http-class">here</a> and the API reference is <a href="http://www.phpfour.com/lib/http">here</a>.</p>
<h3>Cross-domain AJAX calls using PHP</h3>
<p>A minor bug fix in the code. Thanks to a few of you who pointed them out. Original post is <a href="http://www.phpfour.com/blog/2008/03/cross-domain-ajax-using-php/">here</a>. Download the update from <a href="http://www.phpfour.com/blog/downloads/transport">here</a>.</p>
<p>I have accelerated plans for the blog in 2009 so stay tuned for some worthy posts in this month. And do <a href="http://www.phpfour.com/blog/contact-me/">write to me</a> if you feel you have any questions/ideas/suggestions.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>HTTP Class for PHP (supports both cURL and fsockopen)</title>
		<link>http://phpfour.com/blog/2008/01/php-http-class/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-http-class</link>
		<comments>http://phpfour.com/blog/2008/01/php-http-class/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 14:26:50 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[emran]]></category>
		<category><![CDATA[hasan]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/2008/01/20/php-http-class/</guid>
		<description><![CDATA[Feb 2009: A couple bugs have been fixed and library updated. This is a wrapper HTTP class that uses either cURL or fsockopen to harvest resources from the web. It supports a handy subset of functionalists of HTTP that are mostly needed in day to day coding. Scripts who need to communicate with other servers [...]]]></description>
			<content:encoded><![CDATA[<blockquote class="left"><p><strong>Feb 2009:</strong> A couple bugs have been fixed and library updated.</p></blockquote>
<p>This is a wrapper HTTP class that uses either <strong>cURL</strong> or <strong>fsockopen</strong> to harvest resources from the web. It supports a handy subset of functionalists of HTTP that are mostly needed in day to day coding. Scripts who need to communicate with other servers will find it useful. If you&#8217;re looking to invoke any <strong>RESTful </strong>API and don&#8217;t want to bother adding a bunch of libraries for that simple thing, just put this class and you&#8217;re set.</p>
<p><strong>Download</strong></p>
<p>Detailed documentation can be found <a href="http://www.phpfour.com/lib/http" target="_blank">here</a>. And you can download the source from <a href="http://phpfour.com/blog/downloads2" target="_blank">here</a>.</p>
<p><strong>Update</strong></p>
<p><strong></strong>Class added in <a href="http://www.orchidframework.net/">Orchid &#8211; &#8220;PHP framwork for the rest of us&#8221;</a></p>
<h3>Features</h3>
<ul>
<li>Can use both cURL and fsockopen.</li>
<li>Degrades to fsockopen if cURL not enabled.</li>
<li>Supports HTTP Basic authentication.</li>
<li>Supports defining custom request headers.</li>
<li>Supports defining connection timeout values.</li>
<li>Supports defining user agent and referral values.</li>
<li>Supports both user-defined and persistent cookies.</li>
<li>Supports secure connections (HTTPS) with and without cURL.</li>
<li>Supports adding requests parameters for both GET and POST.</li>
<li>Supports automatic redirection (maximum redirect can be defined).</li>
<li>Returns HTTP response headers and response body data separately.</li>
</ul>
<h3>Example 1 &#8211; Simple Get (Facebook Application List)</h3>
<div>
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> &lt;?php</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span> include_once(<span style="color: #006080;">'class.http.php'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span> $http = <span style="color: #0000ff;">new</span> Http();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span> $http-&gt;execute(<span style="color: #006080;">'http://www.facebook.com/apps/index.php?sort=6'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span> echo ($http-&gt;error) ? $http-&gt;error : $http-&gt;result;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span> ?&gt;</pre>
</div>
</div>
<h3>Example 2 &#8211; Invoking Yahoo Term Extraction API</h3>
<div>
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> &lt;?php</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span> include_once(<span style="color: #006080;">'class.http.php'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span> $http = <span style="color: #0000ff;">new</span> Http();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span> $http-&gt;addParam(<span style="color: #006080;">'appid'</span>   , <span style="color: #006080;">'a_really_random_yahoo_app_id'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span> $http-&gt;addParam(<span style="color: #006080;">'context'</span> , <span style="color: #006080;">'I am happy because I bought a new car'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span> $http-&gt;addParam(<span style="color: #006080;">'output'</span>  , <span style="color: #006080;">'xml'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  11:</span> $http-&gt;execute(<span style="color: #006080;">'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  12:</span> echo ($http-&gt;error) ? $http-&gt;error : $http-&gt;result;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  13:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  14:</span> ?&gt;</pre>
</div>
</div>
<h3>Example 3 &#8211; Logging into Basecamp (without using cURL!)</h3>
<div>
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> &lt;?php</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span> include_once(<span style="color: #006080;">'class.http.php'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span> $http = <span style="color: #0000ff;">new</span> Http();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span> $http-&gt;useCurl(<span style="color: #0000ff;">false</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span> $http-&gt;setMethod(<span style="color: #006080;">'POST'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span> $http-&gt;addParam(<span style="color: #006080;">'user_name'</span>, <span style="color: #006080;">'emran'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  11:</span> $http-&gt;addParam(<span style="color: #006080;">'password'</span>, <span style="color: #006080;">'hasan'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  12:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  13:</span> $http-&gt;setReferrer(<span style="color: #006080;">'https://someproject.projectpath.com/login'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  14:</span> $http-&gt;execute(<span style="color: #006080;">'https://someproject.projectpath.com/login/authenticate'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  15:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  16:</span> echo ($http-&gt;error) ? $http-&gt;error : $http-&gt;result;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-botto m-style: none; padding: 0px;"><span style="color: #606060;">  17:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  18:</span> ?&gt;</pre>
</div>
</div>
<h3>Example 4 &#8211; Getting a protected feed</h3>
<div>
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> &lt;?php</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span> include_once(<span style="color: #006080;">'class.http.php'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span> $http = <span style="color: #0000ff;">new</span> Http();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span> $http-&gt;setAuth(<span style="color: #006080;">'emran'</span>, <span style="color: #006080;">'hasan'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span> $http-&gt;execute(<span style="color: #006080;">'http://www.someblog.com/protected/feed.xml'</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span> echo ($http-&gt;error) ? $http-&gt;error : $http-&gt;result;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;">  11:</span> ?&gt;</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2008/01/php-http-class/feed/</wfw:commentRss>
		<slash:comments>45</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 12:51:17 -->
