<?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.evlos.org/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evlos.org</link>
	<description>A straw shows which way the wind blows ..</description>
	<lastBuildDate>Sun, 05 Sep 2010 20:37:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>一个PR图片调用API与查询的程序</title>
		<link>http://www.evlos.org/2010/03/23/google-pr-img-api-v1/</link>
		<comments>http://www.evlos.org/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[小程序 [Lit 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 等一系列服务都很不错。 > 很爽，嘻嘻 O(∩_∩)O。最近打算搞一个 VPS 之类的有更大流量的东东来玩，嘎嘎，春哥保佑。 > 迟一些再发布 AlexImgAPI V1.0.0 吧，其实是还没有完成啦 ╮(╯▽╰)╭，还是代码丢失的老原因。 一. GooglePRImgAPI V1.0.0： > 下面两幅图分别是 Index.php 和 Pr.php 的浏览图，请注意 Index.php 是依赖于 Pr.php 的喔。 > 下载 - http://code.google.com/p/evlosbox/downloads/detail?name=share_primgapi_UI.zip 二. 附言： > 嘿嘿，因为超人童鞋急需，所以先发布这篇，下篇将发布《WP用于围观某评论者发言的插件》。 > 刚刚到手了 Zxc.im nnd.im，嘎嘎嘎，第一个网址是键盘上顺序按键，第二个是NND，O(∩_∩)O。]]></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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/uploads/old/Cap0000255.png' /></p>
<p><img src='http://www.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/uploads/old/Cap0000260.png' /></p>
<p>> 刚刚到手了 Zxc.im nnd.im，嘎嘎嘎，第一个网址是键盘上顺序按键，第二个是NND，O(∩_∩)O。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evlos.org/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.evlos.org/2010/02/12/share-my-alex-text-api/</link>
		<comments>http://www.evlos.org/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[小程序 [Lit 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 的代码共享给大家，祝你玩得愉快喔。 > 有盆友说想要小邪的生成图片的版本，不过有点儿杯具的是小邪不小心弄丢了这段代码。 > http://tool.evlos.org/onlinechk/?do=1，所以这儿还是 Building 状态来着。 > 额，因为小邪对组合图片代码还是不大熟悉，写起来要费一点儿时间，所以迟些共享给大家。 一. Alex自定义文本API： > 使用说明，其实就是Alex.php?u=域名&#038;con=排名的数值保存在[alex]这样的标签里面喔。 > 然后使用 Javascript 调用一下，即用 Script 标签把 Alex.php 的 Url 加参数调用即可。 > [GooglePRTextAPI V1.0.1] - http://code.google.com/p/evlosbox/downloads/detail?name=share_prtextapi.zip > [AlexTextAPI V1.0.3] - http://code.google.com/p/evlosbox/downloads/detail?name=share_alextextapi.zip 二. 帅锅蓝冰： > 嘻嘻，今天帅锅 蓝冰 帮了小邪一个大忙，灰常感谢他，所以小邪顺便帮着打个小张主机广告。 > 广告名为《新年优惠第4波-13号美国西雅图LINUX主机合租CPANEL中文面板-买一送一》。 > 主机演示：http://ourwordpress.com，淘宝店：http://xiaozhang.taobao.com。 三. 菠萝阁奇趣发现： > 小邪开了一个淘宝店铺，叫做 “宝贝奏鸣曲”，嘻，感觉不错 - http://evlos.taobao.com [...]]]></description>
			<content:encoded><![CDATA[<p>> 嘻嘻，那么今天小邪把自己的 Alex 自定义文本 API 的代码共享给大家，祝你玩得愉快喔。<br />
> 有盆友说想要小邪的生成图片的版本，不过有点儿杯具的是小邪不小心弄丢了这段代码。</p>
<p><img src='http://www.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/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.evlos.org/2010/02/10/share-my-google-pr-text-api/</link>
		<comments>http://www.evlos.org/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[小程序 [Lit 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个屁啊”。 > 那么明天小邪打算送出 Alex 可自定义文本的 API，可以 JS 方法调用并输出 “Alex排名:100”。 > ╮(╯o╰)╭，出国时间又延迟了，真是被中介折腾地半死，不过也不错的，小邪可以过完年再走。 一. PR自定义文本调用API： 1. 关于此程序： > 程序名称 - GooglePRTextAPI [更新时间为 - 2010.01.10] [版本号 - v1.01] [性质 - 稳定版] > 程序文件 - [pr.php - 代码与说明] [style.css - CSS 代码] [Cache 缓存文件夹（自动建立）] > [...]]]></description>
			<content:encoded><![CDATA[<p>> 嘎嘎，O(∩ o ∩)O，小邪给大家的新年礼物就只能送送代码咯，╮(╯▽╰)╭，今天送的是 PR Api。<br />
> 这个 API 可以通过 JS 调用方法调用谷歌的 PR 数值，可自定义调用的文字，例如 “3个屁啊”。</p>
<p><img src='http://www.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/uploads/old/Cap0000096_1.jpg' /></p>
<p>> 杯具鸟，╮(╯▽╰)╭，小邪很想把代码发到 Google Code，但是灰常茶几，居然这几天在维护中。</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;">Project hosting will be READ<span style="color: #339933;">-</span>ONLY Wednesday at 8am PST due to brief network maintenance<span style="color: #339933;">.</span></pre></td></tr></table></div>

<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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/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.evlos.org/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.evlos.org/2009/12/14/made-a-api-can-output-alex-image/</link>
		<comments>http://www.evlos.org/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[小程序 [Lit 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 则是提供此网站在其所属国家的排名。 > 记得要加 Url= 喔，不必使用 Http 开头的地址。只支持 6 位数排名，超过则显示无限。 > 正在制作缓存机制，尚未完成喔，缓存时间定为 3 天，这样就不必每次都到官方获取数据咯。 > 预览传送门：http://tool.evlos.org/aleximg/ 1. PHP 中的字符串与数字： > 在 PHP 里，字符串和数字之间是无需转换的，因为它会自动完成这个操作。 > ╮(╯▽╰)╭，我感觉我解脱了，以前在 Delphi 里为了个类型转换就要纠结死，差点就升天了。 1 2 3 4 5 6 &#60;?php $j = &#34;10&#34;; for &#40;$i=1; $i&#60;=$j; $i++&#41; &#123; echo $i; &#125; ?&#62; > 像在 For 循环里，$i 是数字，%j 是字符串，这里就可以直接用啦。 [...]]]></description>
			<content:encoded><![CDATA[<p>> 嘿嘿，这个应该没有其他的人做了吧，独家喔。小邪昨天一直在做这个呢，O(∩_∩)O。<br />
> 很方便的调用，说明在图片上，Type=2 则是提供此网站在其所属国家的排名。</p>
<p><img src="http://www.evlos.org/ev-box/myimg/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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$j</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>> 像在 For 循环里，$i 是数字，%j 是字符串，这里就可以直接用啦。<br />
> 因为加好是针对数值的，点才是针对字符串的。数值上来说 'aass' = 0。<br />
> 所以下面输出的 $i 和 $j 的计算结果都是 1。而 $k 和 $l 都是 1112。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'aass'</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'aass'</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1111'</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$l</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1111'</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'1'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$j</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$k</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$l</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>2. <strong>Url 地址传递参数</strong>：</p>
<p>> 这是一个很方便的功能，不需要表单来引导，但请勿用来传递密码喔。</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;">http<span style="color: #339933;">:</span><span style="color: #096;">//tool.evlos.org/aleximg/get.php?url=verycd.com&amp;type=2</span></pre></td></tr></table></div>

<p>> 这里我就可以使用 $_GET['type'] 来获得需要的参数。<br />
> 记得使用 isset 函数判断参数是否存在喔，不进行判断的话会运行出错的</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$output_type</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</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: #000088;">$output_type</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>3. <strong>Strip_tags 函数</strong>：</p>
<p><img src="http://www.evlos.org/ev-box/myimg/uploads/old/Capture0783.jpg" /></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;p&gt;test&lt;/p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$nop</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>> 这个函数去除 HTML 标签的能力很强悍的说，这样就直接变成了 'test' 啦，O(∩_∩)O。</p>
<p>4. <strong>对中文字符串的支持</strong>：</p>
<p>> 这个支持灰常好，可以像下面的代码一样直接用呢 (^o^)。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$global_num</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'无数据'</span><span style="color: #339933;">||</span>strlen<span style="color: #009900;">&#40;</span><span style="color: #000088;">$global_num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$pic</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;img/global_unlimited.gif&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pic</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: image/jpeg; charset=UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</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: #000088;">$pic_num</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	output_pic<span style="color: #009900;">&#40;</span><span style="color: #000088;">$global_num</span><span style="color: #339933;">,</span><span style="color: #000088;">$output_type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>> 第一次写了 167 行的代码，嘿嘿，记录一下。</p>
<p>5. <strong>使用  PHP 合并数字图片</strong>：</p>
<p>> 呵呵，当时为了自己好理解，而且数量不多，所以在这里就没有使用循环和数组咯。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$source_img1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$source_img2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$source_img3</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img3</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$source_img4</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img4</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$source_img5</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img5</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$source_img6</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_emp.gif'</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: #000088;">$source_img6</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromgif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/num_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$num_cut</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.gif'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<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.evlos.org/2009/12/14/made-a-api-can-output-alex-image/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>制作好一个输出PR图片的API</title>
		<link>http://www.evlos.org/2009/12/09/made-a-api-can-output-pr-image/</link>
		<comments>http://www.evlos.org/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[小程序 [Lit 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 函数的用法。 > 好多服务器为了防采集都禁止 File_get_contents，所以介绍一下俩函数互相替代的方法。 > 话说，昨天给 619 的模板导航栏上加上了分类目录的显示，但我觉得那个模板的函数有点奇怪。 P.s. 呵呵，使用方法如图，作为图片显示即可，有兴趣的童鞋可以调用过去玩玩 O(∩_∩)O。 1. File_get_contents 函数： > 使用如下的代码可以将变量 $GontenPRURL 里的路径指向的文件读入字符串 $filecontent 中。 > 只要在 Url 中传递参数即可到 Google 获取到 PR 的数值，然后转换为相对的图片文件名称。 1 $filecontent = file_get_contents&#40;$prurl&#41;; > 我简单的使用下面的函数代码过滤了一下 Url 地址。 > 因为没法过滤引号，所以后面再使用 Preg_match 的正则式过滤文件头。 1 2 $evlos_re = array&#40;&#34;\&#34;&#34;,&#34;'&#34;,&#34;!&#34;,&#34;@&#34;,&#34;#&#34;,&#34;$&#34;,&#34;%&#34;,&#34;^&#34;,&#34;&#38;&#34;,&#34;*&#34;,&#34;(&#34;,&#34;)&#34;,&#34;+&#34;,&#34;=&#34;&#41;; $website = [...]]]></description>
			<content:encoded><![CDATA[<p>> ╮(╯▽╰)╭ 昨天白夜三更写的，糊涂地忘记了已经有蛮多网站提供这个功能了，结果就杯具了。<br />
> 不过也没什么，这篇文章刚刚好总结一下 Curl 函数和 File_get_contents 函数的用法。</p>
<p><img src="http://www.evlos.org/ev-box/myimg/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.evlos.org/ev-box/myimg/uploads/old/Capture0703.jpg" /></p>
<p>> 使用如下的代码可以将变量 $GontenPRURL 里的路径指向的文件读入字符串 $filecontent 中。<br />
> 只要在 Url 中传递参数即可到 Google 获取到 PR 的数值，然后转换为相对的图片文件名称。</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: #000088;">$filecontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$prurl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>> 我简单的使用下面的函数代码过滤了一下 Url 地址。<br />
> 因为没法过滤引号，所以后面再使用 Preg_match 的正则式过滤文件头。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$evlos_re</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;!&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;@&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;$&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;*&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$website</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$evlos_re</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$website</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>> 最后再输出一个文件头，再把作为字符串的图片接着输出即可。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: image/jpeg; charset=UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>2. <strong>Curl 函数</strong>：</p>
<p>> <strong>注意！！</strong>CURLOPT_URL 参数是不支持相对路径的，网上没看到有人提到，害我差点没折腾挂掉。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ch1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$timeout1</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$prurl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<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: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000088;">$timeout1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$filecontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>> 这里就得用那么长的代码来代替上面 File_get_contents 函数的那一行代码了。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fixurl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fixurl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fixurl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pic</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fixurl</span><span style="color: #339933;">.</span><span style="color: #000088;">$pic</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>> $pic 是我的 PR 图片文件，这里通过上面代码把相对路径转换为 Url 路径。<br />
> 最后也差不多，输出一个文件头，再把作为字符串的图片接着输出即可。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ch2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$timeout2</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$pic</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<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: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000088;">$timeout2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>3. <strong>同行输出日志分类与博客页面列表</strong>：</p>
<p>> 话说原先 Sandbox 只输出博客页面列表的时候 Header.php 只调用了一个函数：</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: #000000; font-weight: bold;">&lt;?php</span> sandbox_globalnav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>> 然后在主题函数 Functions.php 里面加了一大段这个代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sandbox_globalnav<span style="color: #009900;">&#40;</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: #000088;">$menu</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> 
wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=&amp;sort_column=menu_order&amp;echo=0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$menu</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$menu</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$menu</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div id=&quot;menu&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$menu</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'globalnav_menu'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$menu</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>> 我觉得其实没啥必要的样子，因为下面使用 WP 自带的函数输出一个 Li 列表也是可以达到相同效果的。<br />
> 博客页面是 Wp_list_pages，文章分类是 Wp_list_categories。</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;">&lt;div id=&quot;menu&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_categories<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=0&amp;orderby=name&amp;show_count=0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=0&amp;sort_column=menu_order'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;</pre></td></tr></table></div>

<p>> 然后在 CSS 文件里面把 Li 变成行内元素即可，话说 Li 真是一个神奇的东西。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#access</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<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.evlos.org/2009/12/09/made-a-api-can-output-pr-image/feed/</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
	</channel>
</rss>
