<?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>Bolo的博客 &#187; PHP</title>
	<atom:link href="http://blog.imbolo.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.imbolo.com</link>
	<description>一个设计爱好者杂七杂八的博客</description>
	<lastBuildDate>Wed, 01 Sep 2010 04:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress 在 more 截断处插入广告</title>
		<link>http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/</link>
		<comments>http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/#comments</comments>
		<pubDate>Thu, 20 May 2010 05:01:48 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Advertisment]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1847</guid>
		<description><![CDATA[在文章内插入的广告具有相当高的点击率。在 WordPress 里，我发现很多人利用 JavaScript 把广告插入到 more 截断标签处，作为内文广告。昨晚我也在内文里放了 Google Adsense，但我是用 WordPress 自带的 add_filter 函数实现的。]]></description>
			<content:encoded><![CDATA[<p>在文章内插入的广告具有相当高的点击率。在 WordPress 里，我发现很多人利用 JavaScript 把广告插入到 more 截断标签处，作为内文广告。昨晚我也在内文里放了 Google Adsense，但我是用 WordPress 自带的 add_filter 函数实现的。</p>
<p>打开主题的 function.php ，插入下面的代码：</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * The filter to insert the ads
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> bl_insert_ad_code_filter<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$content</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// 只在文章页面显示</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// 首先插入广告代码</span>
	<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div class=&quot;single_ads&quot;&gt;你的广告代码&lt;/div&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// more 标签在 WordPress 2.3 前是一个 a 标签，2.3 后是一个 span 标签</span>
		<span style="color: #666666; font-style: italic;">// 保证兼容性</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#\《(a|span) id＼=<span style="color: #000099; font-weight: bold;">\&quot;</span>more-<span style="color: #006699; font-weight: bold;">$id</span><span style="color: #000099; font-weight: bold;">\&quot;</span>\》\《/<span style="color: #000099; font-weight: bold;">\\</span>1\》#&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$html</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$0</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><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: #666666; font-style: italic;">//因为 wp-syntax 插件的问题，请把上一句代码中的书名号替换成“&lt; ”和“&gt;”，“＼”换成“\”</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bl_insert_ad_code_filter'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>利用这个 filter 我们还可以在文章任意的地方插入广告，或者添加其他的应用，大家可以尽情发挥创意。<span id="more-1847"></span></p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/set-the-first-image-attachment-as-post-thumbnail/" title="自动提取文章第一幅插图作为缩略图">自动提取文章第一幅插图作为缩略图</a></li><li><a href="http://blog.imbolo.com/improve-wordpress-navigation-menu-output/" title="为 WordPress 3.0 自定义菜单添加描述">为 WordPress 3.0 自定义菜单添加描述</a></li><li><a href="http://blog.imbolo.com/customizing-the-new-wordpress-3-0-custom-menus-adding-different-icons-to-each-link/" title="为 WordPress 3.0 的自定义菜单链接添加栏目图标">为 WordPress 3.0 的自定义菜单链接添加栏目图标</a></li><li><a href="http://blog.imbolo.com/wordpress-advance-setting-tips/" title="WordPress 高级设置技巧">WordPress 高级设置技巧</a></li><li><a href="http://blog.imbolo.com/wordpress-plugin-ibegin-share-mod/" title="WordPress 分享插件：iBegin Share (mod)">WordPress 分享插件：iBegin Share (mod)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>PHP 获取远程图片</title>
		<link>http://blog.imbolo.com/php-get-image-from-remote-host/</link>
		<comments>http://blog.imbolo.com/php-get-image-from-remote-host/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 05:54:34 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1766</guid>
		<description><![CDATA[因为大多数虚拟主机都有流量限制（特别是博客主机），因此很多人都选择把图片储存到 Flickr 和 Picasa 等免费相册里，再通过外链插入到文章里。但由于这些网站经常被 block ，因此我建议大家还是尽量把图片放到自己的服务器上。]]></description>
			<content:encoded><![CDATA[<p>因为大多数虚拟主机都有流量限制（特别是博客主机），因此很多人都选择把图片储存到 Flickr 和 Picasa 等免费相册里，再通过外链插入到文章里。但由于这些网站经常被 block ，因此我建议大家还是尽量把图片放到自己的服务器上。</p>
<p>由于我个人很懒，万一博客搬家的话，过多的文章附件将会给文件的迁移带来麻烦。因此我以 cosbeta 的 Pika 插件为蓝本写了一个远程图片代理程序，并对较多博客使用的 Picasa 、 Flickr 和 PhotoBucket 这三个图床服务进行了防止链接被重置的处理。<a href="http://cantonbolo.googlecode.com/files/index.php">请点这里下载脚本</a>。<span id="more-1766"></span></p>
<h3>使用方法</h3>
<p>其实这个脚本和 pika 原理一样，但由于我做了较多的修改，使用方法会有所差别。在使用之前，请确定你拥有符合要求的服务器服务器。</p>
<ul>
<li>一个流量较大的国外php主机</li>
<li>服务器支持curl函数</li>
</ul>
<p>如果能满足以上要求，那么你就可以使用这个脚本了。</p>
<p>首先把脚本上传到国外主机一个子域名的根目录下，并把脚本里的 <strong>$allow_referer</strong> 添加允许调用图片的域名，必须包含此脚本所在的域名和你博客所在的域名，否则图片就无法在你博客显示。</p>
<p>如果你要调用的图片是 Picasa 、 Flickr 和 PhotoBucket 以外的图床，则使用以下的代码（yourdomain是脚本所在的域名）：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strick" style="font-family:monospace;">&lt;img src=&quot;http://yourdomain/index.php?img=http://image_url&quot; /&gt;</pre></td></tr></table></div>

<p>如果你调用的是 Picasa 的图片，则使用以下的代码（ image_url 是 “ggpht.com/” 后面的部分，lh* 是图片外链地址的第一节，也就是服务器编号）：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strick" style="font-family:monospace;">&lt;img src=&quot;http://yourdomain/index.php?img=http://image_url&amp;host=lh*&quot; /&gt;</pre></td></tr></table></div>

<p>调用 Flickr 和 PhotoBucket 的图片也差不多，把 host 参数改为 farm* （Flickr）和 i**** （PhotoBucket）就可以。之所以把这几个图床的调用方法弄得这么麻烦，是因为这几个图床被block的风险比较大，只要调用这几个网站的图片时链接里不出现这几个网站域名，图片链接就不会被重置，从而当这几个网站被block的时候访客也能看到图片。</p>
<p>图片通过此脚本调用一次后会缓存到服务器里，第二次的调用则直接调用缓存。</p>
<h3>PS</h3>
<p>我正在把这个脚本做成一个完整的 WordPress 插件，如果你发现这个脚本有不足的地方，请告诉我。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/" title="WordPress 在 more 截断处插入广告">WordPress 在 more 截断处插入广告</a></li><li><a href="http://blog.imbolo.com/php-print-random-image-from-a-folder/" title="PHP随机显示目录下的图片">PHP随机显示目录下的图片</a></li><li><a href="http://blog.imbolo.com/how-to-get-the-gravatar-picture/" title="如何调用Gravatar头像">如何调用Gravatar头像</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/php-get-image-from-remote-host/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>PHP随机显示目录下的图片</title>
		<link>http://blog.imbolo.com/php-print-random-image-from-a-folder/</link>
		<comments>http://blog.imbolo.com/php-print-random-image-from-a-folder/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 10:23:17 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1501</guid>
		<description><![CDATA[在不久前，推特上，@doublechou（才女，大家follow之）正在做主题（现在她暂时用iNove了）。她当时想做一个随机更换背景图片的功能，用JavaScript写的话，程序流程应该是：建立一个图片数组->随机选择数组里其中一个值->生成样式并写入body标签。]]></description>
			<content:encoded><![CDATA[<h5>前言</h5>
<p>在不久前，推特上，@doublechou（才女，大家follow之，<a rel="external" href="http://doublechou.us/">博客</a>）正在做主题（现在她暂时用iNove了）。她当时想做一个随机更换背景图片的功能，用JavaScript写的话，程序流程应该是：<em>建立一个图片数组-&gt;随机选择数组里其中一个值-&gt;生成样式并写入body标签</em>。<br />
可是用JS做的话，有以下缺点：<br />
1.万一浏览器禁用了JS的话就失效了，而且写代码是需要考虑兼容性。<br />
2.维护比较麻烦，图片的位置都存放在数组里。<br />
于是我提议用PHP处理，可是我和她对PHP都是半桶水的，一时之间也想不出怎么做。今天时运高，看到一个PHP随机显示目录下图片的源码，学习一下，并分享之。<span id="more-1501"></span></p>
<h5>正文</h5>
<p>先看看原理：<em>从一个目录里获取某类型文件的清单（用在WEB的话一般是jpg/gif/png）-&gt;通过随机函数选一个图片-&gt;输出代码</em>。<br />
PHP代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$imglist</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">//用$img_folder变量保存图片所在目录，必须用“/”结尾</span>
 <span style="color: #000088;">$img_folder</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;images/tutorials/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #990000;">mt_srand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>double<span style="color: #009900;">&#41;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//使用目录类</span>
 <span style="color: #000088;">$imgs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img_folder</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//检查目录下是否有图片，并生成一个清单</span>
 <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$imgs</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>read<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">eregi</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;gif&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">eregi</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">eregi</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
     <span style="color: #000088;">$imglist</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$file</span> &quot;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #009900;">&#125;</span> <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgs</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>handle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//把清单里的项都放到一个数组里</span>
 <span style="color: #000088;">$imglist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imglist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imglist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">//生成一个介于0和图片数量之间的随机数</span>
 <span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$no</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$imglist</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$random</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//输出结果</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$img_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$image</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; border=&quot;0/&quot; alt=&quot;&quot; /&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果要通过这个函数变换页面背景的话，可以把最后一句改为：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;body style=&quot;background-image:'</span><span style="color: #339933;">.</span><span style="color: #000088;">$img_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$image</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">;&lt;/</span>body<span style="color: #339933;">&gt;</span></pre></div></div>

<p>并用整段程序替换&lt;body&gt;标签。<br />
如果需要多次调用此程序的话，可以写成一个函数，各位按需要改写。</p>
<h5>总结</h5>
<p>用PHP的方法来输出随机图片的好处是：<br />
1.维护简单，只需要控制目录里图片的数量。<br />
2.可以自定义文件类型，只要你有需要，改成随机输出一个Flash也行的<br />
3.可以自定义输出结果，换句话说，用在什么地方都行了<br />
4.改写成函数后功能更强大</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/css-turn-off-webkit-browsers-input-highlight-and-textarea-resize/" title="CSS 屏蔽 Webkit 浏览器 input 高亮和 textarea 缩放">CSS 屏蔽 Webkit 浏览器 input 高亮和 textarea 缩放</a></li><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/" title="WordPress 在 more 截断处插入广告">WordPress 在 more 截断处插入广告</a></li><li><a href="http://blog.imbolo.com/center-multiple-divs-with-css/" title="CSS 多个子框架居中">CSS 多个子框架居中</a></li><li><a href="http://blog.imbolo.com/the-css3-flexible-box-model/" title="CSS3 灵活的盒子模型(Flexible Box Module) &#8211; 1">CSS3 灵活的盒子模型(Flexible Box Module) &#8211; 1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/php-print-random-image-from-a-folder/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>如何调用Gravatar头像</title>
		<link>http://blog.imbolo.com/how-to-get-the-gravatar-picture/</link>
		<comments>http://blog.imbolo.com/how-to-get-the-gravatar-picture/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 01:43:57 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=1302</guid>
		<description><![CDATA[Gravatar,全称为globally recognized avatar,翻译过来就是全球认证头像.是Wordpress默认使用的大头贴系统.但现在有很多使用Discuz,PHPwind,DedeCMS等建站的人也想利用Gravatar服务作为用户大头贴.下面说说Gravatar大头贴是如何调用的.]]></description>
			<content:encoded><![CDATA[<p>Gravatar,全称为globally recognized avatar,翻译过来就是全球认证头像.是Wordpress默认使用的大头贴系统.但现在有很多使用Discuz,PHPwind,DedeCMS等建站的人也想利用Gravatar服务作为用户大头贴.下面说说Gravatar大头贴是如何调用的.<br />
Gravatar大头贴,是通过用户邮件地址调用的,因此我们应该先把用户邮件地址建立一个变量.用php写一下.</p>

<div class="wp_syntax"><div class="code"><pre class="lang" style="font-family:monospace;">&lt; ?php $mail = //这个变量的值可以通过查询数据库获取,也可以通过系统提供的调用函数获取//; ?&gt;</pre></div></div>

<p>接下来看看Gravatar头像的地址是怎么样的.如下,我的Gravatar地址是这样的:<br />
http://www.gravatar.com/avatar/<span style="color: #ff0000;">53a00852962595b97c5eaad3c5be29eb</span>?<span style="color: #008000;">s=32</span>&amp;<span style="color: #ff6600;">d=</span>&amp;<span style="color: #3366ff;">r=X</span><br />
<span id="more-1302"></span>先解释一下各个参数的作用.<br />
红色部分,经过MD5加密后的字符串,稍后详解.<br />
绿色部分,大头贴尺寸,此处为32&#215;32像素的大头贴.<br />
橙色部分,未明.<br />
蓝色部分,大头贴等级,详情请查阅Gravatar官网相关说明.<br />
留意红色部分,其实那个就是刚才获取的邮件地址,只不过经过了MD5加密,所以下一步我们应该这样处理:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #000088;">$md5</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>嗯,接下来的几个参数自定就可以了,下面整理代码,得出这样一段程序:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bolo1988@qq.com&quot;</span><span style="color: #339933;">;</span>
         <span style="color: #000088;">$md5</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;img src='http://www.gravatar.com/avatar/<span style="color: #006699; font-weight: bold;">$md5</span>?s=32&amp;amp;d=&amp;amp;r=X' /&gt;
?&gt;</span></pre></td></tr></table></div>

<p>上面就是获取邮件地址为bolo1988@qq.com,大小为32&#215;32像素,评级为X的Gravatar大头贴的php程序,大家可以根据需要进行改造.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/wordpress-insert-a-advertisement-at-the-more-tag/" title="WordPress 在 more 截断处插入广告">WordPress 在 more 截断处插入广告</a></li><li><a href="http://blog.imbolo.com/php-get-image-from-remote-host/" title="PHP 获取远程图片">PHP 获取远程图片</a></li><li><a href="http://blog.imbolo.com/php-print-random-image-from-a-folder/" title="PHP随机显示目录下的图片">PHP随机显示目录下的图片</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/how-to-get-the-gravatar-picture/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>
