<?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/"
xmlns:media="http://search.yahoo.com/mrss/"
><channel><title>Yoast&#187; PHP Archives  - Yoast - Tweaking Websites</title> <atom:link href="http://yoast.com/tag/php/feed/" rel="self" type="application/rss+xml" /><link>http://yoast.com</link> <description>Tweaking Websites</description> <lastBuildDate>Sun, 07 Mar 2010 11:56:16 +0000</lastBuildDate> <generator>http://wordpress.org/?v=</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <image><title>Yoast</title> <url>http://netdna.yoast.com/wp-content/themes/yoast-v2/images/yoast-logo-rss.png</url><link>http://yoast.com</link> <width>144</width> <height>103</height> <description>Tweaking Websites</description> </image> <item><title>Magento performance hosting</title><link>http://yoast.com/magento-performance-hosting/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=magento-performance-hosting</link> <comments>http://yoast.com/magento-performance-hosting/#comments</comments> <pubDate>Fri, 12 Jun 2009 07:40:54 +0000</pubDate> <dc:creator>Joachim Houtman</dc:creator> <category><![CDATA[Magento]]></category> <category><![CDATA[Hosting]]></category> <category><![CDATA[performance]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://yoast.com/?p=1489</guid> <description><![CDATA[The system requirements of Magento are quite extensive, it requires at least PHP 5.2.0 extended with mcrypt, PDO_MySql and simplexml. For the database Magento needs at least MySQL 4.1.20 with InnoDB storage engine. At MagentoCommerce.com you can find a complete list of requirements. But how do you know if your server meets these system requirements? [...]<p><a
href="http://yoast.com/magento-performance-hosting/">Magento performance hosting</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>The system requirements of Magento are quite extensive, it requires at least PHP 5.2.0 extended with mcrypt, PDO_MySql and simplexml. For the database Magento needs at least MySQL 4.1.20 with InnoDB storage engine. At <a
href="http://www.magentocommerce.com/system-requirements">MagentoCommerce.com</a> you can find a complete list of requirements. But how do you know if your server meets these system requirements? <a
href="http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento">Check this</a> and follow these three steps.</p><h2>How to get the most out your Magento install?</h2><p>Magento is notorious for it speed and performance. But isn't necessary to have a killer web server to get very reasonable performance, it is all about the configuration of your server and the code of your template. However, after the 1.3 release there are some performance improvements, like <a
href="http://www.magentocommerce.com/blog/comments/magento-version-130-is-now-available/">Frontend Flat Catalog</a>, and people measure reduction of loading times up to 40%. Another recent development is the <a
href="http://www.magentocommerce.com/extension/1359/magento-compiler">Magento Compiler this module</a> compiles all Magento files. From tests this module gave between 25% to 50% better performance. This module is still in beta and should not be used in a production environment for now.</p><p>The question is, what else can you do to speed up your Magento install?</p><h4>Optimize your template for speed</h4><p>More information can be found at the <a
href="http://yoast.com/articles/magento-seo/#speed">Magento SEO</a> article.</p><h4>Enable compression of your files</h4><p>Mod_deflate allows output from your server to be compressed. To enable it for Magento edit your .htaccess, around line 74, in Magento root directory.</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">ifmodule</span> mod_deflate.c&gt;
<span style="color: #adadad; font-style: italic;">############################################</span>
<span style="color: #adadad; font-style: italic;">## enable apache served files compression</span>
<span style="color: #adadad; font-style: italic;">## http://developer.yahoo.com/performance/rules.html#gzip</span>
<span style="color: #adadad; font-style: italic;"># Insert filter</span>
SetOutputFilter DEFLATE
<span style="color: #adadad; font-style: italic;"># Netscape 4.x has some problems...</span>
<span style="color: #00007f;">BrowserMatch</span> ^Mozilla/<span style="color: #ff0000;">4</span> gzip-only-text/html
<span style="color: #adadad; font-style: italic;"># Netscape 4.06-4.08 have some more problems</span>
<span style="color: #00007f;">BrowserMatch</span> ^Mozilla/<span style="color: #ff0000;">4</span>\.0[<span style="color: #ff0000;">678</span>] no-gzip
<span style="color: #adadad; font-style: italic;"># MSIE masquerades as Netscape, but it is fine</span>
<span style="color: #00007f;">BrowserMatch</span> \bMSIE !no-gzip !gzip-only-text/html
<span style="color: #adadad; font-style: italic;"># Don't compress images</span>
<span style="color: #00007f;">SetEnvIfNoCase</span> Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
<span style="color: #adadad; font-style: italic;"># Make sure proxies don't deliver the wrong content</span>
<span style="color: #00007f;">Header</span> append Vary User-Agent env=!dont-vary
&lt;/<span style="color: #000000; font-weight:bold;">ifmodule</span>&gt;</pre></div></div><h4>Apache Module mod_expires</h4><p>mod_expires controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. To enable Expires HTTP header for Magento you had to change the code under <ifmodule
mod_expires.c> at your .htaccess to.</ifmodule></p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">ifmodule</span> mod_expires.c&gt;
<span style="color: #00007f;">ExpiresActive</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">ExpiresDefault</span> <span style="color: #7f007f;">&quot;access plus 1 month&quot;</span>
&lt;/<span style="color: #000000; font-weight:bold;">ifmodule</span>&gt;</pre></div></div><h4>Use PHP Accelerator</h4><p>Install a PHP opcode cacher such as <a
href="http://www.magentocommerce.com/boards/viewthread/9882/">APC</a> or <a
href="http://xcache.lighttpd.net/">XCache</a>. This seems to deliver rather large improvement in the responsive of the Magento install. Some people note a reduce of loading time up to 70%.</p><h4>Tune your MySQL configuration</h4><p>You can modify the configuration of the MySQL server to take advantage of the server's RAM. The efficiency of this step are different, it seems to depends mainly on the number of products. When you have only 100 products, difference will be hardly to notice (below 100ms). But for shops with over 50.000 products there is a huge reduction of the loading time. To give an idea about the settings, for shops with only a limit number of products a query_cache_limit of 1MB will be enough. For larger stores the optimal query cache value can be 64MB. To get the optimal value you really need some testing. A good start point for your <a
href="http://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html">Query Cache configuration</a> can be found here.</p><h4>Speed up your Cache files</h4><p>Magento makes extensive use of file-based storage for caching and session storage. The slowest component in a server is the hard drive, so if you use a memory-based file system such as tmpfs, you can save all those extra disk IO cycles by storing these temporary files in memory instead of storing them on your slow hard drive.</p><h5>Let´s do this with tmpfs</h5><p>Let's say your Magento install is at <code>/var/www/domain.com/</code> so your cache and session directories are <code>/var/www/domain.com/var/cache/</code> and <code>/var/www/domain.com/var/session/</code> For cache we will allocate a max of 256MB RAM and for sessions 64MB RAM. It is important to give access to everyone (e.g your webserver Apache)</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">mount -t tmpfs -o size=256M,mode=0744 tmpfs /var/www/domain.com/var/cache/
mount -t tmpfs -o size=64M,mode=0744 tmpfs /var/www/domain.com/var/session/</pre></div></div><p>Now it might be a good idea to restore these volumes each time your server boots. Just add the following lines to your <code>/etc/fstab</code>:</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">tmpfs /var/www/domain.com/var/cache/ tmpfs size=<span style="color: #ff0000;">256</span>,mode=0744 <span style="color: #ff0000;">0</span> <span style="color: #ff0000;">0</span>
tmpfs /var/www/domain.com/var/session/ tmpfs size=<span style="color: #ff0000;">64</span>,mode=0744 <span style="color: #ff0000;">0</span> <span style="color: #ff0000;">0</span></pre></div></div><p>Please note, your tmpfs is temporary in the sense that nothing will be created on your hard drive. If you reboot, everything in tmpfs will be lost.</p><h5>Save the sessions in your database</h5><p>Another option for the sessions is to save them in your database. Magento supports this very well and it is one small step to make this work. Just edit <code>app/etc/local.xml</code> and set</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">&lt;session_save&gt;&lt;![CDATA[<span style="color: #00007f;">files</span>]]&gt;&lt;/session_save&gt;</pre></div></div><p>to</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">&lt;session_save&gt;&lt;![CDATA[db]]&gt;&lt;/session_save&gt;</pre></div></div><p> it will then save all sessions in the database which is a much quicker access than the filesystem. When you use a cluster enviroment you had to use this option.</p><h4>Enable Apache KeepAlives</h4><p>Enable Apache KeepAlives, this allows persistent connections. These long-lived HTTP sessions allow multiple requests to be send over the same TCP connection, this can result in an almost 50% speedup in latency times for HTML documents with lots of images. An example setting can be:</p><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">KeepAlive</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">KeepAliveTimeout</span> <span style="color: #ff0000;">2</span></pre></div></div><h3>Need more Magento Performance?</h3><p>Ok, you are a very successful online retailer and it is time to cluster, no problem. This means that one single-server doesn't have enough power to keep your customers happy and so you need a clustered environment with two or more servers. A first step can be to start using a Content Delivery Network (CDN). In the low end a Amazon CloudFront/S3 as CDN can be very interesting option.</p><p>The most easy to start is using an separate media server, e.g. media.domain.com. Magento has native support for this. You can configure 'Base Media URL' secure and unsecure under web configurations. This allow you to serve media form one server without the needs to synchronize any directory. Another option is to start using a Content Delivery Network (CDN) for delivering the static files like images. In the low end a Amazon CloudFront/S3 as CDN can be a very interesting option.</p><p>Another option is to use more than one database servers this tactic is called "database replication". One database will be the "master" and all others will be called "slaves". The master is the only database that accepts any sort of write-base queries. These write queries are then replicated to any of the slave servers in real-time. A post at the <a
href="http://www.magentocommerce.com/blog/comments/performance-is-key-notes-on-magentos-performance/">Magento blog</a> will get you on the right track.</p><h4>To summarize, 5 quick wins</h4><ul><li> move the the rules in the .htaccess files from the directories to <a
href="http://www.magentocommerce.com/boards/viewthread/36225/P0/#i9/">virtualhost configuration directives</a></li><li>install Xcache or APC PHP cache accelerator</li><li>clean up your template and layout</li><li>make sure Apache KeepAlives is enabled</li><li>use a memory-based file system for Magento's <code>var/cache/</code> and <code>var/session/</code> directory</li></ul><h3>Conclusion</h3><p>This article give a introduction how to improve your Magento site performance, none of these tips are revolutionary. Because every website's scenario is different, when you really want to get the most out of your Magento install you need to hire a professional. The only way to discover the optimal server configuration is testing, a really great tool to use is <a
href="http://browsermob.com/load-testing">Browsermob</a>, load testing with real web browsers so you will able to put even the Magento checkout process under load testing.</p><p>Now, all of the above you can’t do on your average host, you need a VPS that provides you full control of your server environment. Check out WestHost’s sister company, <a
class="clicky_log_outbound" href="http://yoast.com/out/vpsnet">VPS.net</a>, for a VPS environment that would give you full control.</p><p><a
href="http://yoast.com/magento-performance-hosting/">Magento performance hosting</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/magento-performance-hosting/feed/</wfw:commentRss> <slash:comments>39</slash:comments> </item> <item><title>Easily display your last Tweet</title><link>http://yoast.com/display-latest-tweet/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=display-latest-tweet</link> <comments>http://yoast.com/display-latest-tweet/#comments</comments> <pubDate>Fri, 24 Oct 2008 14:13:45 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Social Media]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Twitter]]></category><guid
isPermaLink="false">http://yoast.com/?p=1269</guid> <description><![CDATA[I wanted to show my latest tweet on the front page of this site, and although I know there are several plugins which probably could've helped me do this, I decided to see how easy the API was to use.
It turned out to be incredibly easy, as long as you have PHP 5.2 or higher, [...]<p><a
href="http://yoast.com/display-latest-tweet/">Easily display your last Tweet</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>I wanted to show my latest tweet on the front page of this site, and although I know there are several plugins which probably could've helped me do this, I decided to see how easy the <a
href="http://apiwiki.twitter.com/REST+API+Documentation">API</a> was to use.</p><p>It turned out to be incredibly easy, as long as you have PHP 5.2 or higher, that is.</p><p>This is the code:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-includes/class-snoopy.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
<span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://twitter.com/statuses/user_timeline/jdevalk.json?count=1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$twitterdata</span> <span style="color: #339933;">=</span> json_decode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div><p>As you can see, I use the Snoopy library to fetch the data, as that comes with WordPress by default.  Than I decode the JSON results by using the <code>json_decode</code> function. This is the reason you need PHP 5.2 or up, as this was only included with this version of PHP.</p><p>Next, we output it. Of course, this is a quick &#038; dirty implementation. If I got dugg now, and 1,000 people a minute came looking at that page, it should have some sort of caching in there. For now though, this is fine as it is!</p><p><strong>Update:</strong> As Kim noticed in the comments, I've added some code to automatically link any @username mentions to those usernames. Replace the last echo line above with this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/\@([a-zA-Z]+)/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a href=&quot;http://twitter.com/'</span><span style="color: #339933;">.</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;@\1&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$output</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span></pre></div></div><p>You could even decide to add <code>rel="nofollow"</code> the <code>$replace</code> if you don't want those links to give juice.</p><p><strong>Update 2:</strong> To make it even more complex, here is the entire code I now use, which excludes replies and caches the Twitter API requests so you won't overload the API:</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: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-includes/class-snoopy.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tweet</span>   <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lasttweet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://twitter.com/statuses/user_timeline/jdevalk.json?count=20&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lastcheck'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">60</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #339933;">;</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$twitterdata</span>   <span style="color: #339933;">=</span> json_decode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'in_reply_to_user_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$pattern</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/\@([a-zA-Z]+)/'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$replace</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a href=&quot;http://twitter.com/'</span><span style="color: #339933;">.</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;@\1&lt;/a&gt;'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
    <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lastcheck'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rawdata'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$twitterdata</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'followers'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'followers_count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lasttweet'</span><span style="color: #339933;">,</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Twitter API not responding.&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$output</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>As you can see it also saves the amount of followers you have into <code>$tweet['followers']</code>, which I then use to display this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">&lt;p&gt;
  &lt;a href=&quot;http://twitter.com/jdevalk&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'followers'</span><span style="color: #009900;">&#93;</span><span style="color: #000000; font-weight: bold;">?&gt;</span> followers on Twitter, and you?
  &lt;/a&gt;
&lt;/p&gt;</pre></div></div><p>Update 3: Another fix to automatically make all links clickable, below this line:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$twitterdata</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>Add:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> make_clickable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>This will use the WordPress internal <code>make_clickable</code> function to make sure that all URL's are clickable.</p><p>Enjoy!</p><p><a
href="http://yoast.com/display-latest-tweet/">Easily display your last Tweet</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/display-latest-tweet/feed/</wfw:commentRss> <slash:comments>68</slash:comments> </item> <item><title>Get the number of popular digg posts for a URL</title><link>http://yoast.com/get-the-number-of-popular-digg-posts-for-a-url/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=get-the-number-of-popular-digg-posts-for-a-url</link> <comments>http://yoast.com/get-the-number-of-popular-digg-posts-for-a-url/#comments</comments> <pubDate>Sun, 25 Nov 2007 09:53:54 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[SEO tools]]></category> <category><![CDATA[Social Media]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/get-the-number-of-popular-digg-posts-for-a-url/</guid> <description><![CDATA[Sometimes, for instance when you're building a domain-info tool, you want to know the number of posts on that site that have made it to the Digg frontpage. After playing a bit, I came up with this pretty easy code:
[code language="php"]
function FrontpageDiggs($url) {
$result['source'] = "http://digg.com/rss_search?search=".$url."&#038;area=promoted&#038;type=url&#038;section=all";
$output = file_get_contents($result['source']);
preg_match_all("/.*().*/",$output,$matches);
$result['result'] = count($matches[1]);
return $result;
}
[/code]
Now if you echo $result['result'], you'll [...]<p><a
href="http://yoast.com/get-the-number-of-popular-digg-posts-for-a-url/">Get the number of popular digg posts for a URL</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>Sometimes, for instance when you're building a <a
href="http://yoast.com/code/domain-info/">domain-info tool</a>, you want to know the number of posts on that site that have made it to the Digg frontpage. After playing a bit, I came up with this pretty easy code:</p><p>[code language="php"]<br
/> function FrontpageDiggs($url) {<br
/> $result['source'] = "http://digg.com/rss_search?search=".$url."&#038;area=promoted&#038;type=url&#038;section=all";<br
/> $output = file_get_contents($result['source']);<br
/> preg_match_all("/.*(<item>).*/",$output,$matches);<br
/> $result['result'] = count($matches[1]);<br
/> return $result;<br
/> }<br
/> [/code]</p><p>Now if you echo $result['result'], you'll get the number of posts for $url that made the frontpage.</item></p><p><a
href="http://yoast.com/get-the-number-of-popular-digg-posts-for-a-url/">Get the number of popular digg posts for a URL</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/get-the-number-of-popular-digg-posts-for-a-url/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>WordPress 301 redirect</title><link>http://yoast.com/wordpress-301-redirect/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-301-redirect</link> <comments>http://yoast.com/wordpress-301-redirect/#comments</comments> <pubDate>Tue, 17 Apr 2007 08:24:20 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/wordpress-301-redirect/</guid> <description><![CDATA[For all you developers out there building WordPress plugins or coding in the core of Wordpress, this is the "proper" way of doing a 301 redirect in WordPress:wp_redirect(get_permalink($url),301);Easy isn't it? Now go off and USE IT. I'm seeing way too much people who forget to add the ",301", and stick with the default, which is [...]<p><a
href="http://yoast.com/wordpress-301-redirect/">WordPress 301 redirect</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>For all you developers out there building WordPress plugins or coding in the core of Wordpress, this is the "proper" way of doing a 301 redirect in WordPress:</p><pre>
wp_redirect(get_permalink($url),301);
</pre><p>Easy isn't it? Now go off and USE IT. I'm seeing way too much people who forget to add the "<code>,301</code>", and stick with the default, which is a 302....</p><p><a
href="http://yoast.com/wordpress-301-redirect/">WordPress 301 redirect</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/wordpress-301-redirect/feed/</wfw:commentRss> <slash:comments>28</slash:comments> </item> <item><title>PHP-APC: Speed up your web applications!</title><link>http://yoast.com/php-apc-speed-web-applications/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-apc-speed-web-applications</link> <comments>http://yoast.com/php-apc-speed-web-applications/#comments</comments> <pubDate>Sun, 08 Apr 2007 08:08:25 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Serverside]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/php-apc-speed-web-appilcations/</guid> <description><![CDATA[As regular readers of this blog might know I have written quite some tools using the different API's of search engines, and always found them quite useful. When I was implementing my sitewide search function, one of the things that bothered me that it was a bit slow. I knew that I had seen some [...]<p><a
href="http://yoast.com/php-apc-speed-web-applications/">PHP-APC: Speed up your web applications!</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>As regular readers of this blog might know I have written quite some tools using the different API's of search engines, and always found them quite useful. When I was implementing my <a
href="http://yoast.com/blog/implementing-a-sitewide-search-function/">sitewide search function</a>, one of the things that bothered me that it was a bit slow. I knew that I had seen some caching implementations on the <a
href="http://developer.yahoo.com/php/">Yahoo PHP developer center</a>, but I hadn't bothered up till then to look at them a bit better.</p><p>Now I did, and I found the <a
href="http://developer.yahoo.com/php/samples/cache/cacheAPC.txt">cacheAPC</a> example to be very, very easy. It relies on the <a
href="http://php.net/apc">Alternative PHP Cache</a>, an opcode cache <a
href="http://pecl.php.net/">PECL</a> extension for PHP. I wrote two functions, which I then put in to all my pieces of code which I've published that use a lot of calls to the different API's. The first is <code>curlopen</code>, the function I use to open connections:</p><pre>function curlopen($request) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $request);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 100);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	$results = curl_exec ($ch);
	curl_close($ch);
	return $results;
}</pre><p>The second one is the actual cache function, look at how easy it is:</p><pre>function request_cache($url, $ttl) {
	if(!$doc = apc_fetch($url)) {
		$doc = curlopen($url);
		if ($doc === false) return false;
		apc_store($url,$doc, $ttl);
	}
	return $doc;
}</pre><p>It basically does three things:</p><ol><li>It looks if the requested resource is already in the cache, and if it is, it fetches that;</li><li>If it's not, it opens it through <code>curlopen</code> and stores it in the cache;</li><li>It returns the requested data;</li></ol><p>As you can see the request_cache function takes two parameters: the request url and the <a
href="http://en.wikipedia.org/wiki/Time_to_live">TTL</a>, which, in seconds, determines how long that resource should be cached. Now if you request a PageRank for a URL, it's fairly safe to set this to 24 hours, and you can see how much requests this saves!</p><p><a
href="http://yoast.com/php-apc-speed-web-applications/">PHP-APC: Speed up your web applications!</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/php-apc-speed-web-applications/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Implementing a sitewide search function</title><link>http://yoast.com/implementing-a-sitewide-search-function/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=implementing-a-sitewide-search-function</link> <comments>http://yoast.com/implementing-a-sitewide-search-function/#comments</comments> <pubDate>Fri, 06 Apr 2007 09:32:26 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Serverside]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/implementing-a-sitewide-search-function/</guid> <description><![CDATA[Those of you coming to this site more often might have noticed a small change in the search box. It's now implemented sitewide, and I've built a sitewide search functions using the Yahoo! API. It was quite nescessary because I found that people were searching for "sortable.zip" on the blog, and they wouldn't find anything [...]<p><a
href="http://yoast.com/implementing-a-sitewide-search-function/">Implementing a sitewide search function</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>Those of you coming to this site more often might have noticed a small change in the search box. It's now implemented sitewide, and I've built a sitewide search functions using the <a
href="http://developer.yahoo.net/about">Yahoo! API</a>. It was quite nescessary because I found that people were searching for "sortable.zip" on the blog, and they wouldn't find anything since the pages for the <a
href="http://yoast.com/code/sortable-table/">sortable table script</a> are static.</p><p><strong>Keeping track of what people are searching for</strong><br
/> I had a few things to make sure while building this search function. First of all, I wanted to have the same info I get when I look at the statistics page for the <a
href="http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/">Search Meter WordPress plugin</a>. Secondly, I wanted to show more then just the post or page title. The last, but also very important demand I have is that it's fast. Well the first one was quite easy, I decided to put  the data into the table for the search meter plugin and just use that interface, instead of writing that myself. The function was basically adapted from the code of the plugin:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> save_search<span style="color: #009900;">&#40;</span><span style="color: #000088;">$searchstring</span><span style="color: #339933;">,</span> <span style="color: #000088;">$numresults</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">global</span> <span style="color: #000088;">$table_prefix</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Save into the DB. Usually this will be a new query, so try to insert first</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO <span style="color: #006699; font-weight: bold;">{$table_prefix}</span>searchmeter (terms,date,count,last_hits) VALUES ('<span style="color: #006699; font-weight: bold;">$searchstring</span>',CURDATE(),1,<span style="color: #006699; font-weight: bold;">$numresults</span>)&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$success</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$success</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE '<span style="color: #006699; font-weight: bold;">{$table_prefix}</span>searchmeter' SET count = count + 1, last_hits = <span style="color: #006699; font-weight: bold;">$numresults</span> WHERE terms = '<span style="color: #006699; font-weight: bold;">$searchstring</span>' AND date = CURDATE()&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$success</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p><strong>Constructing the Yahoo! API query</strong><br
/> The second thing wasn't too hard to do either, as Yahoo! returns a snippet with the searchresult for the query. The <a
href="http://en.wikipedia.org/wiki/Representational_State_Transfer"><abbr
title="Representational State Transfer">REST</abbr></a> query is constructed as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;site:yoast.com+&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$searchstring</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://search.yahooapis.com/WebSearchService/V1/webSearch?appid='</span><span style="color: #339933;">.</span><span style="color: #000088;">$yahooappid</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;query='</span><span style="color: #339933;">.</span><span style="color: #000088;">$query</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;output=php'</span><span style="color: #339933;">;</span></pre></div></div><p>The part <code>output=php</code> makes the API return serialized PHP, which, after calling <code>unserialize</code>, turns into a nice clean array, which you can then loop through to display the results.</p><p>The only thing left was adding the search box to my layout for the non-blog pages, and fixing the blog to look the same. In the theme I had to change the action URL of the searchform.php file to /search/, and there it was: my new site wide search function!</p><p>So far, it's all good. I've got a few things left, like building in paging so you can see more than 10 results. I've got one thing that bothers me though: it's a bit slow. Of course I could solve this by spidering my own site with something like <a
href="http://www.htdig.org/">ht://Dig</a>, but I think there ought to be a better solution... Perhaps you guys and girls know of one?</p><p><a
href="http://yoast.com/implementing-a-sitewide-search-function/">Implementing a sitewide search function</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/implementing-a-sitewide-search-function/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PHP 301 redirects for Apache and IIS</title><link>http://yoast.com/php-301-redirects-apache-iis/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-301-redirects-apache-iis</link> <comments>http://yoast.com/php-301-redirects-apache-iis/#comments</comments> <pubDate>Mon, 02 Apr 2007 20:32:04 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Serverside]]></category> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/php-301-redirects-for-apache-and-iis/</guid> <description><![CDATA[This one is just here for my own reference, because the default 302 status code just isn't good enough!
PHP 301 for Apache:
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/newpage/");
exit;
PHP 301 for IIS:
header("Status: 301 Moved Permanently");
header("Location: http://www.example.com/newpage/");
exit;
PHP 301 redirects for Apache and IIS is a post from Joost de Valk&#39;s Yoast - Tweaking Websites.A good WordPress blog needs [...]<p><a
href="http://yoast.com/php-301-redirects-apache-iis/">PHP 301 redirects for Apache and IIS</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>This one is just here for my own reference, because the default 302 status code just isn't good enough!</p><p>PHP 301 for Apache:</p><pre>header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/newpage/");
exit;</pre><p>PHP 301 for IIS:</p><pre>header("Status: 301 Moved Permanently");
header("Location: http://www.example.com/newpage/");
exit;</pre><p><a
href="http://yoast.com/php-301-redirects-apache-iis/">PHP 301 redirects for Apache and IIS</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/php-301-redirects-apache-iis/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>PHPSESSID in your URL? Learn to 301 redirect them with PHP</title><link>http://yoast.com/phpsessid-url-redirect/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=phpsessid-url-redirect</link> <comments>http://yoast.com/phpsessid-url-redirect/#comments</comments> <pubDate>Fri, 30 Mar 2007 14:36:46 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[SEO]]></category> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/how-to-get-rid-of-phpsessid-in-the-url-and-redirect/</guid> <description><![CDATA[I'm doing some work on a site which has like 4,500 pages indexed with a PHPSESSID in the URL, causing some major duplicate content problems. I got the server admin to disable the PHPSESSID's by adding the following to the vhost config:
php_value session.use_trans_sid 0
php_value session.use_only_cookies 1
I also wanted Google to get a clean URL when [...]<p><a
href="http://yoast.com/phpsessid-url-redirect/">PHPSESSID in your URL? Learn to 301 redirect them with PHP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>I'm doing some work on a site which has like 4,500 pages indexed with a PHPSESSID in the URL, causing some major duplicate content problems. I got the server admin to disable the PHPSESSID's by adding the following to the vhost config:</p><pre>php_value session.use_trans_sid 0
php_value session.use_only_cookies 1</pre><p>I also wanted Google to get a clean URL when it decided to spider one of the old URL's again, and didn't have access to mod_rewrite, so I redirected them with some PHP. The solution is quite simple:</p><pre>if (isset($_GET['PHPSESSID'])) {
	$requesturi = preg_replace('/?PHPSESSID=[^&#038;]+/',"",$_SERVER['REQUEST_URI']);
	$requesturi = preg_replace('/&#038;PHPSESSID=[^&#038;]+/',"",$requesturi);
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://".$_SERVER['HTTP_HOST'].$requesturi);
	exit;
}</pre><p><a
href="http://yoast.com/phpsessid-url-redirect/">PHPSESSID in your URL? Learn to 301 redirect them with PHP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/phpsessid-url-redirect/feed/</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Playing with the del.icio.us Web Badge JSON API using PHP</title><link>http://yoast.com/playing-with-the-delicious-web-badge-json-api-using-php/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=playing-with-the-delicious-web-badge-json-api-using-php</link> <comments>http://yoast.com/playing-with-the-delicious-web-badge-json-api-using-php/#comments</comments> <pubDate>Wed, 20 Dec 2006 13:32:05 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/playing-with-the-delicious-web-badge-json-api-using-php/</guid> <description><![CDATA[Niall Kennedy wrote on his blog that The Yahoo Developer Network provided a short preview of the soon to be released del.icio.us webbadge. From this preview you could see an endpoint and a parameter, so Niall tried and it worked for everyone. That inspired me to make this fast PHP implementation of it, using the [...]<p><a
href="http://yoast.com/playing-with-the-delicious-web-badge-json-api-using-php/">Playing with the del.icio.us Web Badge JSON API using PHP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p><a
href="http://www.niallkennedy.com/blog/archives/2006/12/delicious-url-api.html">Niall Kennedy</a> wrote on his blog that The Yahoo Developer Network provided a <a
href="http://developer.yahoo.net/blog/archives/2006/12/preview_of_the.html">short preview of the soon to be released del.icio.us webbadge</a>. From this preview you could see an endpoint and a parameter, so Niall tried and it worked for everyone. That inspired me to make <a
href="http://yoast.com/code/delicious.php">this fast PHP implementation</a> of it, using the <a
href="http://framework.zend.com/manual/en/zend.json.basics.html">Zend framework JSON library</a>. If you're interested, have a look at <a
href="http://yoast.com/code/delicious.phps">the code</a>.</p><p>[tags]del.icio.us, delicious, API, YDN, Zend, PHP[/tags]</p><p><a
href="http://yoast.com/playing-with-the-delicious-web-badge-json-api-using-php/">Playing with the del.icio.us Web Badge JSON API using PHP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/playing-with-the-delicious-web-badge-json-api-using-php/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Web 2.0 and APIâ€™s: the case for Unlimited queries</title><link>http://yoast.com/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=web-20-and-api%25e2%2580%2599s-the-case-for-unlimited-queries</link> <comments>http://yoast.com/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/#comments</comments> <pubDate>Tue, 05 Dec 2006 13:18:33 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/</guid> <description><![CDATA[Every self respecting search engine has one, loads of other sites have one, and lots of people are using them to make great new stuff: Application Programming Interfaces or APIâ€™s. There's a big 'but' on some of them though...
Wikipedia describes an API as: 'An application programming interface (API) is the interface that a computer system, [...]<p><a
href="http://yoast.com/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/">Web 2.0 and APIâ€™s: the case for Unlimited queries</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>Every self respecting search engine has one, loads of other sites have one, and lots of people are using them to make great new stuff: Application Programming Interfaces or APIâ€™s. There's a big '<em>but</em>' on some of them though...<span
id="more-118"></span></p><p><a
href="http://en.wikipedia.org">Wikipedia</a> describes an <a
href="http://en.wikipedia.org/wiki/API">API</a> as: '<em>An application programming interface (API) is the interface that a computer system, library or application provides in order to allow requests for services to be made of it by other computer programs, and/or to allow data to be exchanged between them.</em>'</p><p>Now these APIâ€™s are super useful, I use them in several of my scripts and have great fun with them. I used the <a
href="http://www.technorati.com/developers/api/">Technorati API</a>, for instance, in the first version of the <a
href="http://yoast.com/code/technorati-rank/">Technorati rank and link count Greasemonkey script</a> I wrote. This was fast, and worked quite well for a while, so I was very happy. After a few hours of browsing though, it stopped working. The error I got was '<em>You have used up your daily allotment of Technorati API queries.</em>'</p><p>Now I canâ€™t understand why theyâ€™d want to limit use of the API like that. Why not? Well, now that I have decided to not use the API (after all how much is 500 queries when you distribute this script to 100+ people?), Iâ€™m left with no other choice but to scrape the content of their normal site. This costs them way and way more bandwidth, and itâ€™s significantly slower. Thatâ€™s not much of a service is it? Remember: I do want to use their services! I want to know the Technorati rank for each page Iâ€™m visiting, thatâ€™s a good sign for them, isnâ€™t it?</p><p>So, please <a
href="http://www.technorati.com">Technorati</a>: get rid of that maximum number of queries. Oh and <a
href="http://www.google.com">Google</a> and <a
href="http://www.yahoo.com">Yahoo!</a>, if youâ€™re listening? Do the same, please!</p><p>[tags]technorati, google, yahoo, api, technorati api, google api, yahoo api, application programming interface[/tags]</p><p><a
href="http://yoast.com/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/">Web 2.0 and APIâ€™s: the case for Unlimited queries</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/web-20-and-api%e2%80%99s-the-case-for-unlimited-queries/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>FeedBurner API fun</title><link>http://yoast.com/feedburner-api-fun/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=feedburner-api-fun</link> <comments>http://yoast.com/feedburner-api-fun/#comments</comments> <pubDate>Mon, 04 Dec 2006 08:06:49 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[RSS]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/feedburner-api-fun/</guid> <description><![CDATA[I've had some fun with the FeedBurner API in the past days, creating a graphic simulation from a blog's feed-readers history over the past year. It's rather elegant, I think, as it creates graphics which you can easily insert into your pages or posts, and will automatically update each time they're loaded.
An example:Want such a [...]<p><a
href="http://yoast.com/feedburner-api-fun/">FeedBurner API fun</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>I've had some fun with the FeedBurner API in the past days, creating a graphic simulation from a blog's feed-readers history over the past year. It's rather elegant, I think, as it creates graphics which you can easily insert into your pages or posts, and will automatically update each time they're loaded.</p><p>An example:</p><p><img
src="http://yoast.com/code/feedburner-graph/?uri=joostdevalk&#038;width=450" alt="Feed circulation data for joostdevalk" /></p><p>Want such a thing for yourself? Go check it out: <a
href="http://yoast.com/code/feedburner-graph/">FeedBurner graph</a>.</p><p>[tags]analytics, feedburner, graphics, feedburner api[/tags]</p><p><a
href="http://yoast.com/feedburner-api-fun/">FeedBurner API fun</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/feedburner-api-fun/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <media:thumbnail url="http://yoast.com/code/feedburner-graph/?uri=joostdevalk&#038;width=450" /> <media:content url="http://yoast.com/code/feedburner-graph/?uri=joostdevalk&#038;width=450" medium="image"> <media:title type="html">Feed circulation data for joostdevalk</media:title> </media:content> </item> <item><title>W3C Validator API</title><link>http://yoast.com/w3c-validator-api/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=w3c-validator-api</link> <comments>http://yoast.com/w3c-validator-api/#comments</comments> <pubDate>Thu, 02 Nov 2006 20:00:42 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Web Design]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/w3c-validator-api/</guid> <description><![CDATA[The W3C announced the release of an API for the HTML validator or rather, that's what they call it. In fact, it's nothing more than an output filter on their normal validator output, which gives SOAP 1.2 conforming output. It requires a HTTP request though, which makes it a rather funny "API" to deal with.
I [...]<p><a
href="http://yoast.com/w3c-validator-api/">W3C Validator API</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>The <a
target="_blank" href=" http://www.w3.org/QA/2006/10/validator_api.html">W3C announced</a> the release of an <a
target="_blank" href="http://validator.w3.org/docs/api.html">API for the HTML validator</a> or rather, that's what they call it. In fact, it's nothing more than an output filter on their normal validator output, which gives SOAP 1.2 conforming output. It requires a HTTP request though, which makes it a rather funny "API" to deal with.<span
id="more-107"></span></p><p>I created a <a
href="http://yoast.com/code/validator.php">simple implementation</a> on top of it, using <a
target="_blank" href="http://php.net/dom">PHP's DOMDocument extension</a> to walk through the result, as using NUSoap or something like that felt like overkill, and it would be hard since the request isn't a SOAP request. It's quite simple, but it's also slow...</p><p>So, my wishlist for the next version of this API:</p><ul><li>a way to do a SOAP request instead of a HTTP request;</li><li>faster, please, please W3C, make it faster;</li><li>a way to specify what info i want, it would be cool to be able to just know if a site is valid or not.</li></ul><p>If they fix that, I'm a happy camper :)</p><p><a
href="http://yoast.com/w3c-validator-api/">W3C Validator API</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/w3c-validator-api/feed/</wfw:commentRss> <slash:comments>21</slash:comments> </item> <item><title>PHP5 and NUSOAP</title><link>http://yoast.com/php5-and-nusoap/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php5-and-nusoap</link> <comments>http://yoast.com/php5-and-nusoap/#comments</comments> <pubDate>Tue, 31 Oct 2006 19:25:17 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[Webdesign & development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/php5-and-nusoap/</guid> <description><![CDATA[So last weekend I installed PHP5 on my server, to finally be able to do some new stuff, and this, it seemed, created some trouble with my SEO scripts that used NUSOAP. What is the problem? Well it's easy: PHP5 has a soapclient built in, and this causes trouble :).
The solution is easy as [...]<p><a
href="http://yoast.com/php5-and-nusoap/">PHP5 and NUSOAP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>So last weekend I installed PHP5 on my server, to finally be able to do some new stuff, and this, it seemed, created some trouble with my SEO scripts that used NUSOAP. What is the problem? Well it's easy: PHP5 has a <code>soapclient</code> built in, and this causes trouble :). <span
id="more-106"></span></p><p>The solution is easy as well, rename <code>class soapclient</code> and <code>function soapclient</code> to <code>nusoapclient</code> in <code>nusoap.php</code>, and make sure you use <code>new nusoapclient</code> instead of <code>new soapclient</code> in your scripts.</p><p><a
href="http://yoast.com/php5-and-nusoap/">PHP5 and NUSOAP</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/php5-and-nusoap/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Getting Google&#039;s last visit date from the Google API</title><link>http://yoast.com/getting-googles-last-visit-date-from-the-google-api/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-googles-last-visit-date-from-the-google-api</link> <comments>http://yoast.com/getting-googles-last-visit-date-from-the-google-api/#comments</comments> <pubDate>Fri, 22 Sep 2006 11:11:46 +0000</pubDate> <dc:creator>Joost de Valk</dc:creator> <category><![CDATA[SEO]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[SEO tools]]></category><guid
isPermaLink="false">http://www.joostdevalk.nl/blog/2006/09/22/getting-googles-last-visit-date-from-the-google-api/</guid> <description><![CDATA[When Vanessa Fox over at the Webmaster Central Blog said they would update the "retrieved on" date even when a page hadn't changed, it suddenly became very cool info. This means you can see when a URL was last spidered, even if you don't have a Sitemaps account for the domain. This triggered me to [...]<p><a
href="http://yoast.com/getting-googles-last-visit-date-from-the-google-api/">Getting Google's last visit date from the Google API</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></description> <content:encoded><![CDATA[<p>When Vanessa Fox over at the <a
target="_blank" href="http://googlewebmastercentral.blogspot.com/">Webmaster Central Blog</a> said they would <a
target="_blank" href="http://googlewebmastercentral.blogspot.com/2006/09/better-details-about-when-googlebot.html">update the "retrieved on" date</a> even when a page hadn't changed, it suddenly became very cool info. This means you can see when a URL was last spidered, even if you don't have a Sitemaps account for the domain. This triggered me to find a way get that date through the Google API, and do nice stuff with it. It worked, and this is how i did it.</p><p><span
id="more-78"></span>First, we have to get the cached page from the Google cache through the API:</p><pre>function GoogleCache($url) {
$soapclient = new soapclient('http://api.google.com/search/beta2');
$soapoptions = 'urn:GoogleSearch';
$params = array(
'key' => [INSERT YOUR GOOGLE API KEY HERE],
'url' => $url
);
$ret = $soapclient->call('doGetCachedPage', $params, $soapoptions);
$err = $soapclient->getError();
return $ret;
}</pre><p>Now we have to make a function which uses this one, and gets the last visit date out of it:</p><pre>function GoogleLastSpidered($url) {
$cache = GoogleCache($url);
preg_match("/.*as retrieved on (.*).
.*/",$cache,$matches);
return $matches[1];
}</pre><p>If you want, you could now feed the output of this function to <a
target="_blank" href="http://nl3.php.net/manual/en/function.strtotime.php">strtotime()</a> to do stuff with the date, or you could just echo it.</p><p>[tags]seo, google api, google cache[/tags]</p><p><a
href="http://yoast.com/getting-googles-last-visit-date-from-the-google-api/">Getting Google's last visit date from the Google API</a> is a post from <a
href="http://yoast.com/about-me/">Joost de Valk</a>&#39;s <a
href="http://yoast.com">Yoast - Tweaking Websites</a>.A good WordPress blog needs good hosting, you don't want your blog to be slow, or, even worse, down, do you? Check out my thoughts on <a
href="http://yoast.com/wordpress-hosting/">WordPress hosting</a>!</p> ]]></content:encoded> <wfw:commentRss>http://yoast.com/getting-googles-last-visit-date-from-the-google-api/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc
Database Caching 3/12 queries in 0.024 seconds using apc
Content Delivery Network via netdna.yoast.com

Served from: yoast.com @ 2010-03-19 04:56:20 -->