<?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>邪罗刹的菠萝阁 &#187; api</title>
	<atom:link href="http://www.rainmoe.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rainmoe.com</link>
	<description>One code, one world ...</description>
	<lastBuildDate>Thu, 29 Dec 2011 14:04:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>一个PR图片调用API与查询的程序</title>
		<link>http://www.rainmoe.com/2010/03/23/google-pr-img-api-v1/</link>
		<comments>http://www.rainmoe.com/2010/03/23/google-pr-img-api-v1/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 21:33:52 +0000</pubDate>
		<dc:creator>小邪</dc:creator>
				<category><![CDATA[作品 [Work]]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[pr]]></category>

		<guid isPermaLink="false">http://www.evlos.org/?p=1945</guid>
		<description><![CDATA[> 嘿嘿，这个是 超人 特别版喔，送给超人童鞋。并附带用户查询界面，为其中的 Index.php 文件。

> 最近觉得 Google 很厚道，日历 阅读器 GMail GoogleCode Appengine 等一系列服务都很不错。



<span class="readmore"><a href="http://www.rainmoe.com/2010/03/23/google-pr-img-api-v1/" title="一个PR图片调用API与查询的程序">阅读全文——共462字</a></span>]]></description>
			<content:encoded><![CDATA[<p>> 嘿嘿，这个是 <a target='_blank' rel='nofollow' href='http://www.superm.org/'>超人</a> 特别版喔，送给超人童鞋。并附带用户查询界面，为其中的 Index.php 文件。<br />
> 最近觉得 Google 很厚道，日历 阅读器 GMail GoogleCode Appengine 等一系列服务都很不错。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000254.png' /></p>
<p>> 很爽，嘻嘻 O(∩_∩)O。最近打算搞一个 VPS 之类的有更大流量的东东来玩，嘎嘎，春哥保佑。<br />
> 迟一些再发布 AlexImgAPI V1.0.0 吧，其实是还没有完成啦 ╮(╯▽╰)╭，还是代码丢失的老原因。</p>
<p><span id="more-1945"></span><strong>一. GooglePRImgAPI V1.0.0：</strong></p>
<p>> 下面两幅图分别是 Index.php 和 Pr.php 的浏览图，请注意 Index.php 是依赖于 Pr.php 的喔。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000255.png' /></p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000256.png' /></p>
<p>> 下载 - <a target='_blank' rel='nofollow' href='http://code.google.com/p/evlosbox/downloads/detail?name=share_primgapi_UI.zip&#038;can=2&#038;q='>http://code.google.com/p/evlosbox/downloads/detail?name=share_primgapi_UI.zip</a></p>
<p><strong>二. 附言：</strong></p>
<p>> 嘿嘿，因为超人童鞋急需，所以先发布这篇，下篇将发布《WP用于围观某评论者发言的插件》。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000260.png' /></p>
<p>> 刚刚到手了 Zxc.im nnd.im，嘎嘎嘎，第一个网址是键盘上顺序按键，第二个是NND，O(∩_∩)O。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rainmoe.com/2010/03/23/google-pr-img-api-v1/feed/</wfw:commentRss>
		<slash:comments>180</slash:comments>
		</item>
		<item>
		<title>共享一个Alex自定义文本API代码</title>
		<link>http://www.rainmoe.com/2010/02/12/share-my-alex-text-api/</link>
		<comments>http://www.rainmoe.com/2010/02/12/share-my-alex-text-api/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 14:52:16 +0000</pubDate>
		<dc:creator>小邪</dc:creator>
				<category><![CDATA[作品 [Work]]]></category>
		<category><![CDATA[alex]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.evlos.org/?p=1928</guid>
		<description><![CDATA[> 嘻嘻，那么今天小邪把自己的 Alex 自定义文本 API 的代码共享给大家，祝你玩得愉快喔。

> 有盆友说想要小邪的生成图片的版本，不过有点儿杯具的是小邪不小心弄丢了这段代码。



<span class="readmore"><a href="http://www.rainmoe.com/2010/02/12/share-my-alex-text-api/" title="共享一个Alex自定义文本API代码">阅读全文——共886字</a></span>]]></description>
			<content:encoded><![CDATA[<p>> 嘻嘻，那么今天小邪把自己的 Alex 自定义文本 API 的代码共享给大家，祝你玩得愉快喔。<br />
> 有盆友说想要小邪的生成图片的版本，不过有点儿杯具的是小邪不小心弄丢了这段代码。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000111.jpg' /></p>
<p>> http://tool.evlos.org/onlinechk/?do=1，所以这儿还是 Building 状态来着。<br />
> 额，因为小邪对组合图片代码还是不大熟悉，写起来要费一点儿时间，所以迟些共享给大家。</p>
<p><span id="more-1928"></span><strong>一. Alex自定义文本API：</strong></p>
<p>> 使用说明，其实就是Alex.php?u=域名&#038;con=排名的数值保存在[alex]这样的标签里面喔。<br />
> 然后使用 Javascript 调用一下，即用 Script 标签把 Alex.php 的 Url 加参数调用即可。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap00001110.jpg' /></p>
<p>> [GooglePRTextAPI V1.0.1] - <a target='_blank' rel='nofollow' href='http://code.google.com/p/evlosbox/downloads/detail?name=share_prtextapi.zip&#038;can=2&#038;q='>http://code.google.com/p/evlosbox/downloads/detail?name=share_prtextapi.zip</a></p>
<p>> [AlexTextAPI V1.0.3] - <a target='_blank' rel='nofollow' href='http://code.google.com/p/evlosbox/downloads/detail?name=share_alextextapi.zip&#038;can=2&#038;q='>http://code.google.com/p/evlosbox/downloads/detail?name=share_alextextapi.zip</a></p>
<p><strong>二. 帅锅蓝冰：</strong></p>
<p>> 嘻嘻，今天帅锅 <a target='_blank' rel='nofollow' href='http://fai.im'>蓝冰</a> 帮了小邪一个大忙，灰常感谢他，所以小邪顺便帮着打个小张主机广告。<br />
> 广告名为《<a target='_blank' rel='nofollow' href='http://hengtian.org/2010/02/05/1081.html'>新年优惠第4波-13号美国西雅图LINUX主机合租CPANEL中文面板-买一送一</a>》。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000113.jpg' /></p>
<p>> 主机演示：<a target='_blank' rel='nofollow' href='http://ourwordpress.com'>http://ourwordpress.com</a>，淘宝店：<a target='_blank' rel='nofollow' href='http://xiaozhang.taobao.com'>http://xiaozhang.taobao.com</a>。</p>
<p><strong>三. 菠萝阁奇趣发现：</strong></p>
<p>> 小邪开了一个淘宝店铺，叫做 “宝贝奏鸣曲”，嘻，感觉不错 - <a target='_blank' rel='nofollow' href='http://evlos.taobao.com'>http://evlos.taobao.com</a></p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000117.jpg' /></p>
<p>> 宝贝地址 - <a target='_blank' rel='nofollow' href='http://item.taobao.com/auction/item_detail-0db1-a9abb4bafbc7640a74cc4b7a255162f6.htm'>http://item.taobao.com/auction/item_detail-0db1-a9abb4bafbc7640a74 ...</a></p>
<p><strong>四. 附言：</strong></p>
<p>> 因为小邪现在换了图床，但是是国内图床，所以借了蓝冰帅锅的域名来用，而且内容要和谐。<br />
> ╮(╯▽╰)╭，没办法，因为小邪的 4 个域名没有一个是备案了的，所以测试图片暂时停止了额。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rainmoe.com/2010/02/12/share-my-alex-text-api/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>共享小邪的PR文本调用API代码</title>
		<link>http://www.rainmoe.com/2010/02/10/share-my-google-pr-text-api/</link>
		<comments>http://www.rainmoe.com/2010/02/10/share-my-google-pr-text-api/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 12:48:02 +0000</pubDate>
		<dc:creator>小邪</dc:creator>
				<category><![CDATA[作品 [Work]]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[pr]]></category>

		<guid isPermaLink="false">http://www.evlos.org/?p=1926</guid>
		<description><![CDATA[> 嘎嘎，O(∩ o ∩)O，小邪给大家的新年礼物就只能送送代码咯，╮(╯▽╰)╭，今天送的是 PR Api。

> 这个 API 可以通过 JS 调用方法调用谷歌的 PR 数值，可自定义调用的文字，例如 “3个屁啊”。



<span class="readmore"><a href="http://www.rainmoe.com/2010/02/10/share-my-google-pr-text-api/" title="共享小邪的PR文本调用API代码">阅读全文——共1359字</a></span>]]></description>
			<content:encoded><![CDATA[<p>> 嘎嘎，O(∩ o ∩)O，小邪给大家的新年礼物就只能送送代码咯，╮(╯▽╰)╭，今天送的是 PR Api。<br />
> 这个 API 可以通过 JS 调用方法调用谷歌的 PR 数值，可自定义调用的文字，例如 “3个屁啊”。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000096.jpg' /></p>
<p>> 那么明天小邪打算送出 Alex 可自定义文本的 API，可以 JS 方法调用并输出 “Alex排名:100”。<br />
> ╮(╯o╰)╭，出国时间又延迟了，真是被中介折腾地半死，不过也不错的，小邪可以过完年再走。</p>
<p><span id="more-1926"></span><strong>一. PR自定义文本调用API：</strong></p>
<p><strong>1. 关于此程序：</strong></p>
<p>> 程序名称 - GooglePRTextAPI [更新时间为 - 2010.01.10] [版本号 - v1.01] [性质 - 稳定版]<br />
> 程序文件 - [pr.php - 代码与说明] [style.css - CSS 代码] [Cache 缓存文件夹（自动建立）]</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000096_1.jpg' /></p>
<p>> 杯具鸟，╮(╯▽╰)╭，小邪很想把代码发到 Google Code，但是灰常茶几，居然这几天在维护中。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
</pre>
<p>> 下载传送门 [Pr.php] - <a target='_blank' rel='nofollow' href='http://code.google.com/p/evlosbox/downloads/detail?name=google_pr_text_api.txt&#038;can=2&#038;q='>http://code.google.com/p/evlosbox/downloads/detail?name=google_pr_text_api.txt</a><br />
> 下载传送门 [style.css] - <a target='_blank' rel='nofollow' href='http://code.google.com/p/evlosbox/downloads/detail?name=google_pr_text_api_css.txt&#038;can=2&#038;q='>http://code.google.com/p/evlosbox/downloads/detail?name=google_pr_text_api_css.txt</a></p>
<p><strong>2. 程序运行时可能造成的影响：</strong></p>
<p>> 程序运行需要使用 Curl 和 File_get_contents 函数，如果你的服务器限制严格，就无法运行了。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000098.jpg' /></p>
<p>> 同时程序会在 Pr.php 同级目录新建一个 Cache 文件夹，里面保存类似 Www_evlos_org.txt。<br />
> 这样子的文件，文件里面的内容是类似于 “2” 这样子的数字，这数字则是对应网站的 PR 数值。</p>
<p>> 上面的文件是缓存文件，缓存时间是 3 天，超过 3 天则会重新到 Google 服务器获取一次 PR。<br />
> 若需要修改缓存时间，请修改 Pr.php 文件的第二行，$cachetime 变量中的数值，单位秒。</p>
<p><strong>二. 菠萝阁奇趣发现：</strong></p>
<p>> 嘻嘻，这个是 <a target='_blank' rel='nofollow' href='http://close.cc/'>JerryChen</a> 写得一个<a target='_blank' rel='nofollow' href='http://u.close.cc/'>短网址程序</a>，也很不错的喔，灰常简洁，也很注重效率呢。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000097.jpg' /></p>
<p>> 今天看到 <a target='_blank' rel='nofollow' href='http://fai.im/'>蓝冰</a> 童鞋在摆弄 <a target='_blank' rel='nofollow' href='http://typecho.org/'>Typecho</a>，小邪感觉灰常心动，╮(╯▽╰)╭，到时候也去弄一个玩玩咯。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000099.jpg' /></p>
<p><strong>三. 附言：</strong></p>
<p>> 是不是又有盆友看不到图片鸟？额，小邪自己测试过了，Poco.cn 全世界都可以访问的说。<br />
> 不会那么杯具吧？！有的盆友请和小邪说，那小邪就立马换微软 Skydrive 网盘服务了喔。<br />
> 至于 Skydrive 网盘的图片可见性，目前可以参见 <a target='_blank' rel='nofollow' href='http://wange.im'>万戈兄</a> 博客中的图片，O(∩_∩)O 呵呵。</p>
<p>> 如果 Skydrive 表现不好的话，就写篇文章，强力赞颂一下 <a target='_blank' rel='nofollow' href='http://zou.lu'>兽兽</a> 的免费精神，嘎嘎。<br />
> 兽兽童鞋提供了一个很不错的公用图床呢，<a target='_blank' rel='nofollow' href='http://zoulu.org/'>http://zoulu.org/</a> 目前表现很不错的说，嘻嘻。</p>
<p><img src='http://www.rainmoe.com/wp-content/uploads/old/Cap0000100.jpg' /></p>
<p>> 还有喔，小邪打算把 <a target='_blank' rel='nofollow' href='http://www.soulsolo.org'>Soulsolo.org</a> 建成一个原创摄影图片的站点，专门放小邪拍的照片。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rainmoe.com/2010/02/10/share-my-google-pr-text-api/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>制作好一个输出Alex排名图片的API</title>
		<link>http://www.rainmoe.com/2009/12/14/made-a-api-can-output-alex-image/</link>
		<comments>http://www.rainmoe.com/2009/12/14/made-a-api-can-output-alex-image/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 07:50:07 +0000</pubDate>
		<dc:creator>小邪</dc:creator>
				<category><![CDATA[作品 [Work]]]></category>
		<category><![CDATA[alex]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.evlos.org/?p=1589</guid>
		<description><![CDATA[> 嘿嘿，这个应该没有其他的人做了吧，独家喔。小邪昨天一直在做这个呢，O(∩_∩)O。

> 很方便的调用，说明在图片上，Type=2 则是提供此网站在其所属国家的排名。



<span class="readmore"><a href="http://www.rainmoe.com/2009/12/14/made-a-api-can-output-alex-image/" title="制作好一个输出Alex排名图片的API">阅读全文——共2587字</a></span>]]></description>
			<content:encoded><![CDATA[<p>> 嘿嘿，这个应该没有其他的人做了吧，独家喔。小邪昨天一直在做这个呢，O(∩_∩)O。<br />
> 很方便的调用，说明在图片上，Type=2 则是提供此网站在其所属国家的排名。</p>
<p><img src="http://www.rainmoe.com/wp-content/uploads/old/Capture0785.jpg" /></p>
<p>> 记得要加 Url= 喔，不必使用 Http 开头的地址。只支持 6 位数排名，超过则显示无限。<br />
> 正在制作缓存机制，尚未完成喔，缓存时间定为 3 天，这样就不必每次都到官方获取数据咯。</p>
<p><span id="more-1589"></span>> 预览传送门：<a target="_blank" href="http://tool.evlos.org/aleximg/">http://tool.evlos.org/aleximg/</a></p>
<p>1. <strong>PHP 中的字符串与数字</strong>：</p>
<p>> 在 PHP 里，字符串和数字之间是无需转换的，因为它会自动完成这个操作。<br />
> ╮(╯▽╰)╭，我感觉我解脱了，以前在 Delphi 里为了个类型转换就要纠结死，差点就升天了。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
&lt;?php
$j = &quot;10&quot;;
for ($i=1; $i&lt;=$j; $i++) {
 echo $i;
}
?&gt;
</pre>
<p>> 像在 For 循环里，$i 是数字，%j 是字符串，这里就可以直接用啦。<br />
> 因为加好是针对数值的，点才是针对字符串的。数值上来说 'aass' = 0。<br />
> 所以下面输出的 $i 和 $j 的计算结果都是 1。而 $k 和 $l 都是 1112。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
&lt;?php
$i = 'aass'+'1';
$j = 'aass'+1;
$k = '1111'+1;
$l = '1111'+'1';
echo $i.' '.$j.' '.$k.' '.$l;
?&gt;
</pre>
<p>2. <strong>Url 地址传递参数</strong>：</p>
<p>> 这是一个很方便的功能，不需要表单来引导，但请勿用来传递密码喔。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
http://tool.evlos.org/aleximg/get.php?url=verycd.com&amp;type=2
</pre>
<p>> 这里我就可以使用 $_GET['type'] 来获得需要的参数。<br />
> 记得使用 isset 函数判断参数是否存在喔，不进行判断的话会运行出错的</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
if(isset($_GET['type'])) {
	$output_type = $_GET['type'];
}
else {
	$output_type = null;
}
</pre>
<p>3. <strong>Strip_tags 函数</strong>：</p>
<p><img src="http://www.rainmoe.com/wp-content/uploads/old/Capture0783.jpg" /></p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$info = '&lt;p&gt;test&lt;/p&gt;';
$nop = strip_tags($info,'&lt;p&gt;');
</pre>
<p>> 这个函数去除 HTML 标签的能力很强悍的说，这样就直接变成了 'test' 啦，O(∩_∩)O。</p>
<p>4. <strong>对中文字符串的支持</strong>：</p>
<p>> 这个支持灰常好，可以像下面的代码一样直接用呢 (^o^)。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
if ($global_num == '无数据'||strlen($global_num)&gt;6) {
	$pic=&quot;img/global_unlimited.gif&quot;;
	$content = file_get_contents($pic);
	header(&quot;Content-Type: image/jpeg; charset=UTF-8&quot;);
	echo $content;
}
else {
	$pic_num = '';
	output_pic($global_num,$output_type);
}
</pre>
<p>> 第一次写了 167 行的代码，嘿嘿，记录一下。</p>
<p>5. <strong>使用  PHP 合并数字图片</strong>：</p>
<p>> 呵呵，当时为了自己好理解，而且数量不多，所以在这里就没有使用循环和数组咯。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
if ($num_cut[0] == null) {$source_img1 = imagecreatefromgif('img/num_emp.gif');}
else {$source_img1 = imagecreatefromgif('img/num_'.$num_cut[0].'.gif');}
if ($num_cut[1] == null) { $source_img2 = imagecreatefromgif('img/num_emp.gif'); }
else { $source_img2 = imagecreatefromgif('img/num_'.$num_cut[1].'.gif'); }
if ($num_cut[2] == null) { $source_img3 = imagecreatefromgif('img/num_emp.gif'); }
else { $source_img3 = imagecreatefromgif('img/num_'.$num_cut[2].'.gif'); }
if ($num_cut[3] == null) { $source_img4 = imagecreatefromgif('img/num_emp.gif'); }
else { $source_img4 = imagecreatefromgif('img/num_'.$num_cut[3].'.gif'); }
if ($num_cut[4] == null) { $source_img5 = imagecreatefromgif('img/num_emp.gif'); }
else { $source_img5 = imagecreatefromgif('img/num_'.$num_cut[4].'.gif'); }
if ($num_cut[5] == null) { $source_img6 = imagecreatefromgif('img/num_emp.gif'); }
else { $source_img6 = imagecreatefromgif('img/num_'.$num_cut[5].'.gif'); }
</pre>
<p>6 .<strong>请注意一下</strong>：</p>
<p>> 如果有哪个童鞋打算长期使用，请一定要和我说一声。<br />
> 有出现某些不得不做改动的情况的话，我会立即通知你做修改的。<br />
> 还有使用了我的 PR 调用的童鞋也麻烦吱我一声，谢谢支持。</p>
<p>7. <strong>欢迎来 Follow 我的 Twitter <a target="_blank" rel="nofollow" href="http://twitter.com/angelsolo">@AngelSolo</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rainmoe.com/2009/12/14/made-a-api-can-output-alex-image/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>制作好一个输出PR图片的API</title>
		<link>http://www.rainmoe.com/2009/12/09/made-a-api-can-output-pr-image/</link>
		<comments>http://www.rainmoe.com/2009/12/09/made-a-api-can-output-pr-image/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:35:07 +0000</pubDate>
		<dc:creator>小邪</dc:creator>
				<category><![CDATA[作品 [Work]]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pr]]></category>

		<guid isPermaLink="false">http://www.evlos.org/?p=1490</guid>
		<description><![CDATA[> ╮(╯▽╰)╭ 昨天白夜三更写的，糊涂地忘记了已经有蛮多网站提供这个功能了，结果就杯具了。

> 不过也没什么，这篇文章刚刚好总结一下 Curl 函数和 File_get_contents 函数的用法。



<span class="readmore"><a href="http://www.rainmoe.com/2009/12/09/made-a-api-can-output-pr-image/" title="制作好一个输出PR图片的API">阅读全文——共2672字</a></span>]]></description>
			<content:encoded><![CDATA[<p>> ╮(╯▽╰)╭ 昨天白夜三更写的，糊涂地忘记了已经有蛮多网站提供这个功能了，结果就杯具了。<br />
> 不过也没什么，这篇文章刚刚好总结一下 Curl 函数和 File_get_contents 函数的用法。</p>
<p><img src="http://www.rainmoe.com/wp-content/uploads/old/Capture0704.jpg" /></p>
<p>> 好多服务器为了防采集都禁止 File_get_contents，所以介绍一下俩函数互相替代的方法。<br />
> 话说，昨天给 619 的模板导航栏上加上了分类目录的显示，但我觉得那个模板的函数有点奇怪。</p>
<p>P.s. 呵呵，使用方法如图，作为图片显示即可，有兴趣的童鞋可以调用过去玩玩 O(∩_∩)O。</p>
<p><span id="more-1490"></span>1. <strong>File_get_contents 函数</strong>：</p>
<p><img src="http://www.rainmoe.com/wp-content/uploads/old/Capture0703.jpg" /></p>
<p>> 使用如下的代码可以将变量 $GontenPRURL 里的路径指向的文件读入字符串 $filecontent 中。<br />
> 只要在 Url 中传递参数即可到 Google 获取到 PR 的数值，然后转换为相对的图片文件名称。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$filecontent = file_get_contents($prurl);
</pre>
<p>> 我简单的使用下面的函数代码过滤了一下 Url 地址。<br />
> 因为没法过滤引号，所以后面再使用 Preg_match 的正则式过滤文件头。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$evlos_re = array(&quot;\&quot;&quot;,&quot;'&quot;,&quot;!&quot;,&quot;@&quot;,&quot;#&quot;,&quot;$&quot;,&quot;%&quot;,&quot;^&quot;,&quot;&amp;&quot;,&quot;*&quot;,&quot;(&quot;,&quot;)&quot;,&quot;+&quot;,&quot;=&quot;);
$website = str_replace($evlos_re,&quot;&quot;,$website);
</pre>
<p>> 最后再输出一个文件头，再把作为字符串的图片接着输出即可。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
header(&quot;Content-Type: image/jpeg; charset=UTF-8&quot;);
echo $content;
</pre>
<p>2. <strong>Curl 函数</strong>：</p>
<p>> <strong>注意！！</strong>CURLOPT_URL 参数是不支持相对路径的，网上没看到有人提到，害我差点没折腾挂掉。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$ch1 = curl_init();
$timeout1 = 15;
curl_setopt ($ch1, CURLOPT_URL, $prurl);
curl_setopt ($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch1, CURLOPT_CONNECTTIMEOUT, $timeout1);
$filecontent = curl_exec($ch1);
curl_close($ch1);
</pre>
<p>> 这里就得用那么长的代码来代替上面 File_get_contents 函数的那一行代码了。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$fixurl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$fixurl = str_replace(basename($_SERVER['PHP_SELF']),&quot;&quot;,$fixurl);
$pic = $fixurl.$pic;
</pre>
<p>> $pic 是我的 PR 图片文件，这里通过上面代码把相对路径转换为 Url 路径。<br />
> 最后也差不多，输出一个文件头，再把作为字符串的图片接着输出即可。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
$ch2 = curl_init();
$timeout2 = 15;
curl_setopt ($ch2, CURLOPT_URL, $pic);
curl_setopt ($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch2, CURLOPT_CONNECTTIMEOUT, $timeout2);
$content = curl_exec($ch2);
curl_close($ch2);
</pre>
<p>3. <strong>同行输出日志分类与博客页面列表</strong>：</p>
<p>> 话说原先 Sandbox 只输出博客页面列表的时候 Header.php 只调用了一个函数：</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
&lt;?php sandbox_globalnav() ?&gt;
</pre>
<p>> 然后在主题函数 Functions.php 里面加了一大段这个代码：</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
function sandbox_globalnav() {
	if ( $menu = str_replace( array( &quot;\r&quot;, &quot;\n&quot;, &quot;\t&quot; ), '',
wp_list_pages('title_li=&amp;sort_column=menu_order&amp;echo=0') ) )
		$menu = '&lt;ul&gt;' . $menu . '&lt;/ul&gt;';
	$menu = '&lt;div id=&quot;menu&quot;&gt;' . $menu . &quot;&lt;/div&gt;\n&quot;;
	echo apply_filters( 'globalnav_menu', $menu );
}
</pre>
<p>> 我觉得其实没啥必要的样子，因为下面使用 WP 自带的函数输出一个 Li 列表也是可以达到相同效果的。<br />
> 博客页面是 Wp_list_pages，文章分类是 Wp_list_categories。</p>
<pre class="brush: php; auto-links: false; html-script: false; title: ; notranslate">
&lt;div id=&quot;menu&quot;&gt;
&lt;?php wp_list_categories('title_li=0&amp;orderby=name&amp;show_count=0');
wp_list_pages('title_li=0&amp;sort_column=menu_order'); ?&gt;
&lt;/div&gt;
</pre>
<p>> 然后在 CSS 文件里面把 Li 变成行内元素即可，话说 Li 真是一个神奇的东西。</p>
<pre class="brush: css; auto-links: false; html-script: false; title: ; notranslate">
#access li {
display:inline;
padding-left:8px;
}
</pre>
<p>4. <strong>调用说明页面传送门</strong>：</p>
<p>> <a target="_blank" href="http://tool.evlos.org/primg/">http://tool.evlos.org/primg/</a></p>
<p>5. <strong>欢迎来 Follow 我的 Twitter <a target="_blank" rel="nofollow" href="http://twitter.com/angelsolo">@AngelSolo</a></strong> 。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rainmoe.com/2009/12/09/made-a-api-can-output-pr-image/feed/</wfw:commentRss>
		<slash:comments>71</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached (Feed is rejected)
Page Caching using memcached
Database Caching 1/24 queries in 0.015 seconds using memcached
Object Caching 421/473 objects using memcached

Served from: www.rainmoe.com @ 2012-02-09 16:40:43 -->
