<?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; Twitter</title>
	<atom:link href="http://blog.imbolo.com/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.imbolo.com</link>
	<description>一个设计爱好者杂七杂八的博客</description>
	<lastBuildDate>Wed, 23 Nov 2011 16:19:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>为奶瓶腿增加img.ly推特图床服务API</title>
		<link>http://blog.imbolo.com/add-img-ly-api-to-netputweets/</link>
		<comments>http://blog.imbolo.com/add-img-ly-api-to-netputweets/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 10:07:25 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Dabr]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1716</guid>
		<description><![CDATA[奶瓶腿是一个由 @NetPuter 修改、架设的一个安全的、个性的中文 Twitter 手机客户端，基于 Dabr 源码，在国内非常流行。但是直到目前的最新版（NetPutweets_2009_Final_SP2，发布于2010年1月3日）还没有支持时下最流行的img.ly推图服务。]]></description>
			<content:encoded><![CDATA[<p>奶瓶腿（英文名： Netputweets，<a href="http://code.google.com/p/netputweets/" rel="external nofollow">开源地址</a>）是一个由 @NetPuter 修改、架设的一个安全的、个性的中文 Twitter 手机客户端，基于 Dabr 源码，在国内非常流行。但是直到目前的最新版（NetPutweets_2009_Final_SP2，发布于2010年1月3日）还没有支持时下最流行的img.ly推图服务。这也对一些喜欢贴图的用户造成了一定的不便，因为奶瓶腿默认的图片上传服务twitpic在国内已经不能访问了，现在写一下为奶瓶腿在上传图片时给用户提供图片服务选择和预览img.ly图片的方法。</p>
<h3>1.提供图片服务选项</h3>
<p>这个方法参考了《<a href="http://felixcat.net/2010/01/add-more-picture-upload-services-to-dabr/" rel="external nofollow">给dabr添加多种图片上传服务</a>》，但选择太多有时反而是累赘，保留大众的就行，因此我精简了一下。</p>
<p>打开common/menu.php，在 <strong>function theme_menu_toptop</strong> 和 <strong>function theme_menu_bottomtom</strong> 都进行以下修改。<span id="more-1716"></span></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: #666666; font-style: italic;">//找到</span>
<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href='&quot;</span><span style="color: #339933;">.</span>BASE_URL<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;twitpic'&gt;&quot;</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Twitpic&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//改为</span>
<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href='&quot;</span><span style="color: #339933;">.</span>BASE_URL<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;picture'&gt;&quot;</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Twitpic&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>再打开common/twitter.php，找到 <strong>&#8216;callback&#8217; => &#8216;twitter_twitpic_page&#8217;</strong> 改为 <strong>&#8216;callback&#8217; => &#8216;twitter_picture_page&#8217;</strong> ，并找到下面这段代码：</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> twitter_twitpic_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</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>user_type<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'oauth'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You can\'t use Twitpic uploads while accessing Dabr using an OAuth login.&quot;</span><span style="color: #009900;">&#41;</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>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> twitter_process<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://twitpic.com/api/uploadAndPost'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'media'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'@'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'media'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> user_current_username<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$GLOBALS</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;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</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: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#mediaid&gt;(.*)&quot;.__(&quot;Upload success.&quot;).&quot;&lt;p&gt;&lt;img src='</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//twitpic.com/show/thumb/{$query[2]}' alt='' /&gt;&lt;/p&gt;&quot;;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</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;">'fail'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Twitpic upload failed. No idea why!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/p&gt;'</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;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;form method=&quot;post&quot; action=&quot;'</span><span style="color: #339933;">.</span>BASE_URL<span style="color: #339933;">.</span><span style="color: #0000ff;">'twitpic&quot; enctype=&quot;multipart/form-data&quot;&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Image&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' &lt;input type=&quot;file&quot; name=&quot;media&quot; /&gt;&lt;br /&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">': &lt;input type=&quot;text&quot; name=&quot;message&quot; maxlength=&quot;120&quot; /&gt;&lt;br /&gt;&lt;input type=&quot;submit&quot; value=&quot;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Upload&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;&lt;/form&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Twitpic Upload&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>我这里是增加img.ly、twic.li和twitsnaps的选项，因此替换成下面这段代码：</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
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> twitter_picture_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</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>user_type<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'oauth'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You can\'t use Twitpic uploads while accessing Dabr using an OAuth login.&quot;</span><span style="color: #009900;">&#41;</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>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ms1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$ms2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ms1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'service'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'twitpic'</span><span style="color: #339933;">:</span>
			<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> twitter_process<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://twitpic.com/api/upload'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'media'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'@'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'media'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> user_current_username<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$GLOBALS</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;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#mediaurl&gt;(.*) '</span><span style="color: #339933;">@</span><span style="color: #0000ff;">'.$_FILES['</span>media<span style="color: #0000ff;">']['</span>tmp_name<span style="color: #0000ff;">'],
			'</span>username<span style="color: #0000ff;">' =&gt; user_current_username(),
			'</span>password<span style="color: #0000ff;">' =&gt; $GLOBALS['</span>user<span style="color: #0000ff;">']['</span>password<span style="color: #0000ff;">'],
		));
		if (preg_match('</span><span style="color: #666666; font-style: italic;">#mediaurl&gt;(.*) '@'.$_FILES['media']['tmp_name'],
</span>			<span style="color: #0000ff;">'tweet'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ms2</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> user_current_username<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$GLOBALS</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;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</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: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#square_url&gt;(.*) '</span><span style="color: #339933;">@</span><span style="color: #0000ff;">'.$_FILES['</span>media<span style="color: #0000ff;">']['</span>tmp_name<span style="color: #0000ff;">'],
			'</span>message<span style="color: #0000ff;">' =&gt; $ms2,
			'</span>user_name<span style="color: #0000ff;">' =&gt; user_current_username(),
			'</span>password<span style="color: #0000ff;">' =&gt; $GLOBALS['</span>user<span style="color: #0000ff;">']['</span>password<span style="color: #0000ff;">'],
		));
		if (preg_match('</span><span style="color: #666666; font-style: italic;">#imageurl&gt;(.*)Picture upload to $query[2] success.&quot;;
</span>	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</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;">'fail'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'service'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;p&gt;Picture upload to <span style="color: #006699; font-weight: bold;">$query[2]</span> failed. No idea why!&lt;/p&gt;&quot;</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;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;form method='post' action='picture' enctype='multipart/form-data'&gt;Service: &lt;select name='service'&gt;&lt;option value='imgly'&gt;Img.ly&lt;/option&gt;&lt;option value='twitpic'&gt;twitpic&lt;/option&gt;&lt;option value='twicli'&gt;Twic.li&lt;/option&gt;&lt;option value='twitsnaps'&gt;TwitSnaps&lt;/option&gt;&lt;br /&gt;Image: &lt;input type='file' name='media' /&gt;&lt;br /&gt;Message: &lt;input type='text' name='message' maxlength='120' /&gt;&lt;br /&gt;&lt;input type='submit' value='Upload' /&gt;&lt;/select&gt;&lt;/form&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Picture Upload'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>至此上传图片到img.ly的API已经添加到奶瓶腿里了，晒图页面效果如下：</p>
<p><img src="http://i1001.photobucket.com/albums/af131/bolo1988/3d2adf51.png" alt="奶瓶腿增加图床服务选项" /></p>
<h3>2.预览img.ly图片</h3>
<p>奶瓶腿已经支持很多图床服务的预览功能，但一直没有加入对img.ly图片的预览，这也是一个美中不足，继续修改common/twitter.php，找到<strong>function twitter_photo_replace</strong>，进行以下修改：</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//把下面代码</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#img.ly/([\w\d]+)#i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tmp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_PATTERN_ORDER<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://img.ly/show/thumb/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$match</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href='http://img.ly/<span style="color: #006699; font-weight: bold;">{$match}</span>'&gt;&lt;img src='<span style="color: #006699; font-weight: bold;">$thumb</span>' /&gt;&lt;/a&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//插入到</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#twitgoo.com/([\d\w]+)#'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tmp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_PATTERN_ORDER<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href='http://twitgoo.com/<span style="color: #006699; font-weight: bold;">{$match}</span>'&gt;&lt;img src='http://twitgoo.com/show/thumb/<span style="color: #006699; font-weight: bold;">{$match}</span>' class='twitpic' /&gt;&lt;/a&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//的下方</span></pre></td></tr></table></div>

<p>改完这部奶瓶腿已经完全支持img.ly图片服务了，下面是我加入img.ly图片预览后的截图。</p>
<p><img src="http://i1001.photobucket.com/albums/af131/bolo1988/imgly.png" alt="奶瓶腿imgly预览" /></p>
<p  class="related_post_title">Random Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/defense-the-malicious-site-by-host/" title="巧用windows的host文件防范恶意网站">巧用windows的host文件防范恶意网站</a></li><li><a href="http://blog.imbolo.com/cctv-said-google-aggrieve-teenagers-health/" title="央视谴责google严重侵害青少年身心健康">央视谴责google严重侵害青少年身心健康</a></li><li><a href="http://blog.imbolo.com/some-points-of-graphics-design/" title="图形设计应该注意的几个要点">图形设计应该注意的几个要点</a></li><li><a href="http://blog.imbolo.com/join-in-wordpress-jam/" title="加入WordPress Jam">加入WordPress Jam</a></li><li><a href="http://blog.imbolo.com/full-width-navigation-bar/" title="等宽导航栏">等宽导航栏</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/add-img-ly-api-to-netputweets/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

