<?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>Tarotoast's Stuff &#187; Programming</title>
	<atom:link href="http://blog.tarotoast.com/category/it/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tarotoast.com</link>
	<description>Personal blog</description>
	<lastBuildDate>Tue, 04 May 2010 08:49:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>php + curl = convenient</title>
		<link>http://blog.tarotoast.com/2006/07/17/262/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-curl-convenient</link>
		<comments>http://blog.tarotoast.com/2006/07/17/262/#comments</comments>
		<pubDate>Tue, 18 Jul 2006 02:20:13 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[Footprints + Diary]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/07/17/262/</guid>
		<description><![CDATA[There nothing major or significant going on in my life and therefore I did not bother writing anything down, for quite a while, as you might know. Anyway, today I&#39;m writing a little utility to help fetching images on remote server and store it into sequential names, all within PHP. To initiate a curl request, [...]]]></description>
			<content:encoded><![CDATA[<p>There nothing major or significant going on in my life and therefore I did not bother writing anything down, for quite a while, as you might know. Anyway, today I&#39;m writing a little utility to help fetching images on remote server and store it into sequential names, all within PHP.</p>
<p>To initiate a curl request, you declare one like this:</p>
<blockquote><p>$c = curl_init(&quot;http://server/page.html?getopt=value&quot;);</p></blockquote>
<p>Then set options for this curl request:</p>
<blockquote><p>curl_setopt($c, CURLOPT_RETURNTRANSFER,1); // stops the request from outputting immediately</p>
<p>curl_setopt($c, CURLOPT_USERAGENT, &quot; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)&quot;); // use a very legit fake useragent</p>
<p>curl_setopt($c, CURLOPT_REFERER, &quot;http://server&quot;); // bypassing measures preventing hotlinking/stealing/whatever u&#39;d like to call it</p></blockquote>
<p>A complete listing of all available curl options is <a href="http://us2.php.net/manual/en/function.curl-setopt.php">here</a>. After the options are set, execute the request and store the result like this:</p>
<blockquote><p>$result = curl_exec($c);</p>
<p>$curlinfo = curl_getinfo($c);</p>
<p>$httperrorcode = $info[&#39;http_code&#39;];</p></blockquote>
<p>If the query is proper, the $httperrorcode should be 200. Assuming you&#39;ve successfully (200) obtained the targeted document, these are helpful methods to use to manipulate/store the data:</p>
<ul>
<li>strlen( $var )</li>
<li>str_replace( &quot;replace this with&quot;, &quot;this&quot;, $from_this )</li>
<li>explode( &quot;seperator&quot;, $turn_into_array )</li>
<li>sizeof( $var )</li>
<li>strstr( $does_this_contain, &quot;this&quot; )</li>
<li>print( $var )</li>
<li>echo( $var )</li>
<li>mkdir( &quot;ABSPATH&quot;, 0777)</li>
<li>$fp = fopen( &quot;ABSFILENAME&quot;, &#39;w&#39; );</li>
<li>fwrite( $fp, $result )</li>
<li>fclose( $fp )</li>
</ul>
<p style="margin-left: 40px">&nbsp;</p>
<p style="margin-left: 40px">&nbsp;</p>
<p>After the whatever-purpose php script is done, simply use the following way to execute under console:</p>
<blockquote><p>php filename.php getopt1=val1 getopt2=val2</p></blockquote>
<p>Of course, you access those val1 and val2 within the program with $_GET[&#39;getopt1&#39;] and etc.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/07/17/262/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>old vb project</title>
		<link>http://blog.tarotoast.com/2005/08/02/19/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=old-vb-project</link>
		<comments>http://blog.tarotoast.com/2005/08/02/19/#comments</comments>
		<pubDate>Wed, 03 Aug 2005 06:41:24 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[College (Mesa)]]></category>
		<category><![CDATA[Footprints + Diary]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://tarotoast.com/wordpress/?p=19</guid>
		<description><![CDATA[http://www.tarotoast.com/www/project/]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tarotoast.com/www/project/">http://www.tarotoast.com/www/project/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2005/08/02/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
