<?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>Blackhat SEOCode — Blackhat SEO &#187;</title>
	<atom:link href="http://www.blackhat-seo.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blackhat-seo.com</link>
	<description>rants from the dark side of marketing</description>
	<lastBuildDate>Sun, 02 May 2010 22:26:49 +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>Decaptcher PHP API</title>
		<link>http://www.blackhat-seo.com/2009/decaptcher-php-api/</link>
		<comments>http://www.blackhat-seo.com/2009/decaptcher-php-api/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 10:54:18 +0000</pubDate>
		<dc:creator>countzero</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.blackhat-seo.com/?p=346</guid>
		<description><![CDATA[I rewrote Decaptcher&#8217;s PHP monstrosity yesterday. My version is a single class and doesn&#8217;t use three dozen constants. You can find the source below: http://svn.blackhat-seo.com/stuff/php/Decaptcher/ Copyright 2010, BLACKHAT-SEO.COM This post is originally from http://www.blackhat-seo.com/. If you want more like this, visit my website to subscribe. (#fnkey: b4e6bbb02fae174c227d407f9522b5a0 (38.107.191.94) )]]></description>
			<content:encoded><![CDATA[<p>I rewrote Decaptcher&#8217;s PHP monstrosity yesterday. My version is a single class and doesn&#8217;t use three dozen constants. You can find the source below:</p>
<p><a href="http://svn.blackhat-seo.com/stuff/php/Decaptcher/">http://svn.blackhat-seo.com/stuff/php/Decaptcher/</a></p>
<hr/>
<small>
Copyright 2010, BLACKHAT-SEO.COM<br/>
This post is originally from <a href="http://www.blackhat-seo.com/">http://www.blackhat-seo.com/</a>. If you want more like this, visit my website to subscribe. <br/><em> (#fnkey:  b4e6bbb02fae174c227d407f9522b5a0 (38.107.191.94) )</em></small>]]></content:encoded>
			<wfw:commentRss>http://www.blackhat-seo.com/2009/decaptcher-php-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deferred chain</title>
		<link>http://www.blackhat-seo.com/2009/deferred-chain/</link>
		<comments>http://www.blackhat-seo.com/2009/deferred-chain/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 16:33:49 +0000</pubDate>
		<dc:creator>countzero</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.blackhat-seo.com/?p=338</guid>
		<description><![CDATA[A few months ago, I wrote a small PHP class to help me create chainable interfaces (PHP people like to call these &#8220;fluent interfaces&#8221;) without having to retrofit old code. I call this DeferredChain. Here is the source for DeferredChain. The idea is that you extend DeferredChain and write a bunch of methods prefixed with [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I wrote a small PHP class to help me create chainable interfaces (PHP people like to call these &#8220;fluent interfaces&#8221;) without having to retrofit old code. I call this DeferredChain.</p>
<p>Here is the <a href="http://svn.blackhat-seo.com/stuff/php/Chains/DeferredChain.php">source for DeferredChain</a>.</p>
<p><span id="more-338"></span></p>
<p>The idea is that you extend DeferredChain and write a bunch of methods prefixed with &#8216;_&#8217;. These don&#8217;t have to return $this to enable you to chain them.</p>
<p><code><br />
class MyChain extends DeferredChain {</p>
<p>  protected function _doSomething() {<br />
    $f = file_get_contents('something.txt');<br />
    return $f;<br />
  }</p>
<p>  // you can have method arguments of course<br />
  protected function _doSomethingElse($x) {<br />
    return $x*2;<br />
  }<br />
}</p>
<p>$m = new MyChain;<br />
$m->doSomething()->doSomethingElse(42);</p>
<p>//do whatever</p>
<p>// execute your chain step by step<br />
while($res = $m->doNext()) {<br />
  $results[] = $res ;<br />
  echo $res;<br />
}</p>
<p>// or all steps at once<br />
$results = $m->doAll();<br />
</code></p>
<p>If you are still reading this post, here is a more interesting example.</p>
<p><code><br />
$d = new DiggChain($user,$pass);</p>
<p>$d->login()->profile()<br />
->index()->diggStories(4)->index()<br />
->category()->buryStories(2)<br />
->category('general')->diggMine($story_id)<br />
->index();</p>
<p>$c = new CurlBase;</p>
<p>while(($requests = $d->doNext())) {<br />
  $c->addArr($requests);<br />
  $c->perform();<br />
}<br />
</code></p>
<p>Here is the <a href="http://svn.blackhat-seo.com/stuff/php/Chains/DiggChain.php">incomplete DiggChain</a>.</p>
<p>This is how I like to write glue for loosely coupled cURL requests. For example, I wouldn&#8217;t use chains for just a series of HTTP requests that login at a website. I have been using the <a href="http://curlobjects.com">Curl Objects</a> library, which provides a specialized class for tightly coupled HTTP requests. You should probably check that out if you use php-cURL.</p>
<p>Well that&#8217;s it for today. Stay tuned for more coding related posts.</p>
<hr/>
<small>
Copyright 2010, BLACKHAT-SEO.COM<br/>
This post is originally from <a href="http://www.blackhat-seo.com/">http://www.blackhat-seo.com/</a>. If you want more like this, visit my website to subscribe. <br/><em> (#fnkey:  b4e6bbb02fae174c227d407f9522b5a0 (38.107.191.94) )</em></small>]]></content:encoded>
			<wfw:commentRss>http://www.blackhat-seo.com/2009/deferred-chain/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
