<?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>DemiLane &#187; PHP</title>
	<atom:link href="http://demilane.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://demilane.com</link>
	<description>Pages of Rogelio Calamaya</description>
	<lastBuildDate>Sun, 20 Jun 2010 19:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Tabbed Navigation in WordPress</title>
		<link>http://demilane.com/tabbed-navigation-in-wordpress/</link>
		<comments>http://demilane.com/tabbed-navigation-in-wordpress/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 08:18:35 +0000</pubDate>
		<dc:creator>Rogelio</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.demilane.com/?p=455</guid>
		<description><![CDATA[I encountered this problem when I&#8217;m developing my first wordpress theme, a very simple problem and I want to share this tutorial to all of you. Hopefully it will give you an basic idea on how to make a tabbed navigation in you wordpress theme. Now, in our template file where our navigation is located(in ]]></description>
			<content:encoded><![CDATA[<p>I encountered this problem when I&#8217;m developing my first wordpress theme, a very simple problem and I want to share this tutorial to all of you. Hopefully it will give you an basic idea on how to make a tabbed navigation in you wordpress theme.</p>
<p>Now, in our template file where our navigation is located(<em>in my case, header.php</em>). We will paste the code below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;ul id=&quot;nav&quot;&gt;
  &lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'class=&quot;current_page_item&quot;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;
    &lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;Home&quot;&gt;Home&lt;/a&gt;
  &lt;/li&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> 
     wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sort_column=menu_order&amp;title_li=&amp;depth=-1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></td></tr></table></div>

<p>The style:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> li <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">12px</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> li<span style="color: #6666ff;">.current_page_item</span> a<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#60a013</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> li a<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#60a013</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The code above will give the result, a simple tabbed navigation with an <code>:active</code> and <code>:hover</code> effect:</p>
<p><img class="size-full wp-image-457 aligncenter" title="wp-tabbed-final" src="http://demilane.com/wp-content/uploads/2009/06/wp-tabbed-final.jpg" alt="wp-tabbed-final" width="378" height="78" /></p>
<p>Notice that we add a &#8220;Home&#8221; link before we call the pages, to determine if the additional link is active we use the conditional tag <code>is_home()</code>. The <code>is_home()</code> returns true when the main blog page is currently being displayed, in our code if it&#8217;s true then it well print the <code>class="current_page_item"</code> else it will print nothing. More information about the conditional tags can be found <strong><a href="http://codex.wordpress.org/Conditional_Tags">here</a></strong>.</p>
<p>And we display the pages link using the <code>wp_list_pages()</code> template tag. We can customize the output of our links by using the parameters <code>sort_column=menu_order</code>, <code>title_li=''</code> and <code>depth=-1</code>.</p>
<p>The <code>sort_column=menu_order</code> can sort the list of pages in a different way. In our code we will sort the pages by Page Order. Page order can be set by user in the pages administrative panel. Next is <code>title_li=''</code>, this will not display headings and the list will not be wrapped with <code>&lt;ul&gt;...&lt;/ul&gt;</code>. And last <code>depth=-1</code>, will display the sub-pages as flat, the same as the other pages with no indent form. More information about the <code>wp_list_pages()</code> template tag can be found <strong><a href="http://codex.wordpress.org/Template_Tags/wp_list_pages">here</a></strong></p>


<p>Related posts:<ol><li><a href='http://demilane.com/sudden-change-of-theme-wordpress-2-8/' rel='bookmark' title='Permanent Link: Sudden Change of Theme: WordPress 2.8'>Sudden Change of Theme: WordPress 2.8</a></li>
<li><a href='http://demilane.com/twit-with-php/' rel='bookmark' title='Permanent Link: Twit with PHP[updated]'>Twit with PHP[updated]</a></li>
<li><a href='http://demilane.com/8-arm-creature-wp-theme/' rel='bookmark' title='Permanent Link: 8 Arm Creature WP-Theme'>8 Arm Creature WP-Theme</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://demilane.com/tabbed-navigation-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ta-da-da-da! Operation Reboot</title>
		<link>http://demilane.com/operation-reboot/</link>
		<comments>http://demilane.com/operation-reboot/#comments</comments>
		<pubDate>Mon, 04 May 2009 06:11:15 +0000</pubDate>
		<dc:creator>Rogelio</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wallpaper]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.demilane.com/?p=282</guid>
		<description><![CDATA[Hello, from niflheim. I just noticed that my blog went hiatus. It&#8217;s been awhile since my last post. I&#8217;ve been busy lately, busy watching random anime series and busy playing random video games, I even forgot my work. Anyways here are some wallpapers and stuff that I haven&#8217;t publish in my blog for these past ]]></description>
			<content:encoded><![CDATA[<p>Hello, from niflheim. I just noticed that my blog went hiatus. It&#8217;s been awhile since my last post. I&#8217;ve been busy lately, busy watching random anime series and busy playing random video games, I even forgot my work. Anyways here are some wallpapers and stuff that I haven&#8217;t publish in my blog for these past months:</p>
<p><a href="http://chanlu.org/wallpapers/"><img class="size-full wp-image-284 alignleft" title="dsanta-san" src="http://demilane.com/wp-content/uploads/2009/05/dsanta-san.jpg" alt="dsanta-san" width="243" height="95" /></a></p>
<p>D. Santa-san is a wallpaper I created right after my third <a href="http://demilane.com/hello-santa-san">Gig Poster Design</a>. You could say that it&#8217;s the wallpaper version but it has nothing to do with the gig. This is for <a href="http://chanlu.org/wallpapers/">chanlu&#8217;s Christmas</a> update.</p>
<div class="clear"></div>
<p><strong>Download:</strong> <a href="http://chanlu.org/wallpapers/download/20/7" target="_blank">D. Santa-san 1440 x 900</a></p>
<p><a href="http://chanlu.org/wallpapers/"><img class="size-full wp-image-292 alignleft" title="see-no-evil" src="http://demilane.com/wp-content/uploads/2009/05/see-no-evil.jpg" alt="see-no-evil" width="243" height="95" /></a></p>
<p>This wallpaper is a collaboration work with <a href="http://blog.pixelmai.com/">Charlotte</a>, The character was done by her and everything except the character were made by me. This wallpaper has a pair, the other is <a href="http://chasama.deviantart.com/art/What-lies-behind-102171290">here</a>, a girl.</p>
<div class="clear"></div>
<p><strong>Download:</strong> <a href="http://chanlu.org/wallpapers/download/21/5" target="_blank">See No Evil 1440 x 900</a></p>
<p><a href="http://github.com/rogelio/twitty/"><img class="size-full wp-image-294 alignleft" title="twitty" src="http://demilane.com/wp-content/uploads/2009/05/twitty.jpg" alt="twitty" width="243" height="95" /></a></p>
<p>Six months ago, I started liking <a href="http://twitter.com">Twitter</a>, that&#8217;s the story. My incomplete twitter API library for PHP called <strong>twitty</strong>, just a little project and my first time in writing such library. It&#8217;s still in development though.</p>
<div class="clear"></div>
<p><strong>Download:</strong> <a href="http://github.com/rogelio/twitty/" target="_blank">Twitty for PHP</a></p>


<p>Related posts:<ol><li><a href='http://demilane.com/twit-with-php/' rel='bookmark' title='Permanent Link: Twit with PHP[updated]'>Twit with PHP[updated]</a></li>
<li><a href='http://demilane.com/halloween-wallpaper/' rel='bookmark' title='Permanent Link: Halloween Wallpaper'>Halloween Wallpaper</a></li>
<li><a href='http://demilane.com/wallpaper-calendar-october-2009/' rel='bookmark' title='Permanent Link: Wallpaper Calendar: October 2009'>Wallpaper Calendar: October 2009</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://demilane.com/operation-reboot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twit with PHP[updated]</title>
		<link>http://demilane.com/twit-with-php/</link>
		<comments>http://demilane.com/twit-with-php/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 07:52:47 +0000</pubDate>
		<dc:creator>Rogelio</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.demilane.com/?p=163</guid>
		<description><![CDATA[While my brain cells are doomed to extinction in writing my pangram, I&#8217;ve written a simple tutorial on how to send a twitter updates using PHP. And I think this will be good while I&#8217;m waiting for my brain cells to regenerates. This tutorial requires CURL library installed for PHP, it&#8217;s use for communicating with ]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="twitter" src="http://demilane.com/wp-content/uploads/2008/12/twitter.jpg" alt="twi^&amp;@#t!" width="232" height="139" />While my brain cells are doomed to extinction in writing my <a href="http://demilane.com/pangrammic-autogram">pangram</a>, I&#8217;ve written a simple tutorial on how to send a twitter updates using PHP. And I think this will be good while I&#8217;m waiting for my brain cells to regenerates.</p>
<p>This tutorial requires <a href="http://curl.haxx.se/" target="_blank">CURL</a> library installed for PHP, it&#8217;s use for communicating with the <a href="http://apiwiki.twitter.com/" target="_blank">Twitter API</a>. Here is the <a href="http://blog.demilane.com/dl/twitterphp/twitter.php">demo</a> of the script.</p>
<p>Read at the bottom for <a href="#twitphpupdate">updates</a>.</p>
<p>So, let&#8217;s begin:<br />
First we declare the following variables.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://twitter.com/statuses/update.xml'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Set your Status here'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The variable <code>$user</code> and <code>$pass</code> are of course your username and password in your twitter account. The <code>$twitter</code> is the URL of the <a href="http://apiwiki.twitter.com/REST+API+Documentation#update">updates</a> for the Twitter API with the <code>status</code> parameter, <code>$status</code> is where the status/update will be store.</p>
<p>Then, let&#8217;s do the curl. We will create a curl session.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Set the necessary options for our session. This is where our variables will be needed.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">.</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">.</span><span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$twitter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;status=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expect:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first option, the CURLOPT_USERPWD is where you define your username and password in a format of [<em>username</em>]:[<em>password</em>] to use for our request. Next the CURLOPT_POST, we need to define this as true because the request must be a POST. Then the CURLOPT_URL, is where the URL to do our request. And lastly the CURLOPT_RETURNTRANSFER, it returns the value of our curl execution(<em>later</em>) as a string instead of printing it directly to the browser.</p>
<p>We execute and catch the status of our request.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">curl_exec</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$HttpCode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLINFO_HTTP_CODE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$HttpCode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
   <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your status has been updated'</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">401</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Not Authorized: invalid username or password.'</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'An unknown error has occured. Try Again'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endswitch</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here, after we executed the curl, we would like to get the status of our last request with the function <code>curl_getinfo()</code> with the option CURLINFO_HTTP_CODE. This will let us know what our last HTTP code, since the Twitter API returns the appropriate <a href="http://apiwiki.twitter.com/REST+API+Documentation#HTTPStatusCodes">HTTP Status code</a> for every request.</p>
<p>Lastly, we close our session and frees all resources.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And that&#8217;s all.</p>
<p><strong>The complete code:</strong><br />
Here is the complete code that are describe above. You can use/modify in any way you want.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://twitter.com/statuses/update.xml'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Set your Status here'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">.</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">.</span><span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$twitter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;status=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expect:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_exec</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$HttpCode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLINFO_HTTP_CODE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$HttpCode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
   <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your status has been updated'</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">401</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Not Authorized: invalid username or password.'</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'An unknown error has occured. Try Again'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endswitch</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a name="twitphpupdate"></a></p>
<h3>Updates for HTTP/1.1 clients</h3>
<p>I&#8217;ve check <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0update">twitter API</a> and there are a lot of changes ever since I write this post, so here are the updates:</p>
<p>Since it is a post operation, we&#8217;ve set</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;status=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And for the HTTP/1.1 clients thats getting an Http response of 100, we&#8217;ve overwrite the expectation to empty in our header when sending our request. <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20">Link</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expect:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Comment out, if your&#8217;re having problem.</p>
<p><strong><a href="http://demilane.com/dl/twitterphp/twitter_php.zip">Download</a></strong> || <strong><a href="http://demilane.com/dl/twitterphp/twitter.php">View Demo</a></strong></p>


<p>Related posts:<ol><li><a href='http://demilane.com/operation-reboot/' rel='bookmark' title='Permanent Link: Ta-da-da-da! Operation Reboot'>Ta-da-da-da! Operation Reboot</a></li>
<li><a href='http://demilane.com/tabbed-navigation-in-wordpress/' rel='bookmark' title='Permanent Link: Tabbed Navigation in WordPress'>Tabbed Navigation in WordPress</a></li>
<li><a href='http://demilane.com/how-to-use-microsoft-speech-object-library/' rel='bookmark' title='Permanent Link: Using Microsoft Speech Object Library in VB6'>Using Microsoft Speech Object Library in VB6</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://demilane.com/twit-with-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
