<?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; 饭否</title>
	<atom:link href="http://www.watch-life.net/tag/%e9%a5%ad%e5%90%a6/feed" rel="self" type="application/rss+xml" />
	<link>http://www.watch-life.net</link>
	<description>关注IT,审视自我,守望生活, 宁静雅致的小轩馆.</description>
	<lastBuildDate>Mon, 23 Aug 2010 15:08:58 +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>使用PHP调用Twitter的RSS</title>
		<link>http://www.watch-life.net/php/php-twitter-rss.html</link>
		<comments>http://www.watch-life.net/php/php-twitter-rss.html#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:06:08 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[滔滔]]></category>
		<category><![CDATA[腾讯]]></category>
		<category><![CDATA[饭否]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=500</guid>
		<description><![CDATA[“守望轩”博客右侧边栏原来有个“杂感”的栏目，用来记录短的、不能大篇幅成文的短句，或者自己比较喜欢的短句和言论。 这个栏目最开始调用微博饭否的API来做的，因为众所周知的缘故，饭否无法使用了，后来采用腾讯的滔滔API来实现.2010年1月26日滔滔业务将会开始和QQ空间心情整合，只能考虑放弃。思来想去，最终还是考虑用Twitter来实现，不过Twitter在国内无法访问，不能采用js的方式来调用。本博客的服务器才国外，用php的方式访问Twitter的API应该没有问题，虽然有现成的wordpress插件“Twitter Tools”可以用，但本着尽量少用插件的目的，决定直接用php在wordpress主题里实现。twritter提供的API接口很丰富，研究一下觉得调用Twitter RSS的API比较简单，实现如下功能： 2010-04-14：发现twitter的rss访问不正常，导致获取数据失败，而原来的代码对$xml-&#62;channel-&#62;item数组没有进行正确性的判断，调整代码，加入有关判断。 1、抓取twitter RSS的内容，不需要密码，只需要用户名。 2、格式化RSS的内容，显示用户本人的推的内容及时间，排除 @replies 回复给他人的信息内容。 代码如下： 01: &#60;!-- my tritter --&#62; 02: &#60;?php 03: $username='xjb';//change this to your twitter username修改为你的twitter 用户名 04: $feedURL='http://twitter.com/statuses/user_timeline/'.$username.'.rss'; 05: $excludePattern='/'.$username.': @/'; //excludes any @replies排除@replies 内容 06: $count=5;// show count 07: $i=0; 08: 09: if(!$xml=simplexml_load_file($feedURL)){ 10: trigger_error('Error',E_USER_ERROR); 11: } 12: if ( isset($xml-&#62;channel-&#62;item) &#124;&#124; is_array($xml-&#62;channel-&#62;item) ) [...]]]></description>
			<content:encoded><![CDATA[<p>“<a href="http://www.watch-life.net" target="_blank">守望轩</a>”博客右侧边栏原来有个“杂感”的栏目，用来记录短的、不能大篇幅成文的短句，或者自己比较喜欢的短句和言论。<br />
<img src="http://www.watch-life.net/images/fanfou.jpg" border="0" alt="杂感" /><br />
这个栏目最开始调用微博<a href="http://zh.wikipedia.org/wiki/%E9%A5%AD%E5%90%A6" target="_blank">饭否</a>的API来做的，因为众所周知的缘故，<a href="http://www.watch-life.net/tag/%E9%A5%AD%E5%90%A6" target="_blank">饭否</a>无法使用了，后来采用<a href="http://www.qq.com/" target="_blank">腾讯</a>的<a href="http://www.taotao.com/" target="_blank">滔滔</a>API来实现.2010年1月26日滔滔业务将会开始和QQ空间心情整合，只能考虑放弃。思来想去，最终还是考虑用<a href="http://www.watch-life.net/tag/twitter" target="_blank">Twitter</a>来实现，不过<a href="http://zh.wikipedia.org/wiki/Twitter" target="_blank">Twitter</a>在国内无法访问，不能采用js的方式来调用。本博客的服务器才国外，用php的方式访问Twitter的API应该没有问题，虽然有现成的<a rel="tag" href="http://www.watch-life.net/tag/wordpress" target="_blank">wordpress</a>插件“<a href="http://wordpress.org/extend/plugins/twitter-tools/" target="_blank">Twitter Tools</a>”可以用，但本着尽量少用插件的目的，决定直接用php在<a href="http://wordpress.org/" target="_blank">wordpress</a>主题里实现。twritter提供的API接口很丰富，研究一下觉得调用Twitter <a rel="tag" href="http://www.watch-life.net/tag/rss" target="_blank">RSS</a>的<a rel="tag" href="http://www.watch-life.net/tag/api" target="_blank">API</a>比较简单，实现如下功能：</p>
<p><span style="color: blue;">2010-04-14：发现twitter的rss访问不正常，导致获取数据失败，而原来的代码对<span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">$xml-&gt;channel-&gt;item数组没有进行正确性的判断，调整代码，加入有关判断。</span></span></p>
<p><strong>1、抓取twitter RSS的内容，不需要密码，只需要用户名。<br />
2、格式化RSS的内容，显示用户本人的推的内容及时间，排除 @replies 回复给他人的信息内容。</strong></p>
<p>代码如下：</p>
<div class="code">
<pre class="code"><span style="color: black; font-weight: bold;">01:  </span><span style="color: green;">&lt;!--  my tritter  --&gt;
<span style="color: black; font-weight: bold;">02:  </span></span><span style="color: blue;">&lt;?php
<span style="color: black; font-weight: bold;">03:  </span>$username</span><span style="color: purple;">=</span><span style="color: olive;">'xjb'</span>;<span style="color: green;">//change this to your twitter username修改为你的twitter 用户名
<span style="color: black; font-weight: bold;">04:  </span></span><span style="color: blue;">$feedURL</span><span style="color: purple;">=</span><span style="color: olive;">'http://twitter.com/statuses/user_timeline/'</span><span style="color: purple;">.</span><span style="color: blue;">$username</span><span style="color: purple;">.</span><span style="color: olive;">'.rss'</span>;
<span style="color: black; font-weight: bold;">05:  </span><span style="color: blue;">$excludePattern</span><span style="color: purple;">=</span><span style="color: olive;">'/'</span><span style="color: purple;">.</span><span style="color: blue;">$username</span><span style="color: purple;">.</span><span style="color: olive;">': @/'</span>; <span style="color: green;">//excludes any @replies排除@replies 内容
<span style="color: black; font-weight: bold;">06:  </span></span><span style="color: blue;">$count</span><span style="color: purple;">=</span><span style="color: red;">5</span>;<span style="color: green;">//  show count
<span style="color: black; font-weight: bold;">07:  </span></span><span style="color: blue;">$i</span><span style="color: purple;">=</span><span style="color: red;">0</span>;
<span style="color: black; font-weight: bold;">08:  </span>
<span style="color: black; font-weight: bold;">09:  </span><span style="color: blue;">if</span><span style="color: purple;">(!</span><span style="color: blue;">$xml</span><span style="color: purple;">=</span>simplexml_load_file<span style="color: purple;">(</span><span style="color: blue;">$feedURL</span><span style="color: purple;">)){
<span style="color: black; font-weight: bold;">10:  </span>  </span>trigger_error<span style="color: purple;">(</span><span style="color: olive;">'Error'</span><span style="color: purple;">,</span>E_USER_ERROR<span style="color: purple;">)</span>;
<span style="color: black; font-weight: bold;">11:  </span><span style="color: purple;">}
<span style="color: black; font-weight: bold;">12:  </span></span><span style="color: blue;">if </span><span style="color: purple;">( </span><span style="color: blue;">isset</span><span style="color: purple;">(</span><span style="color: blue;">$xml</span><span style="color: purple;">-&gt;</span>channel<span style="color: purple;">-&gt;</span>item<span style="color: purple;">) || </span>is_array<span style="color: purple;">(</span><span style="color: blue;">$xml</span><span style="color: purple;">-&gt;</span>channel<span style="color: purple;">-&gt;</span>item<span style="color: purple;">) )
<span style="color: black; font-weight: bold;">13:  </span>    {
<span style="color: black; font-weight: bold;">14:  </span>        </span><span style="color: blue;">foreach</span><span style="color: purple;">(</span><span style="color: blue;">$xml</span><span style="color: purple;">-&gt;</span>channel<span style="color: purple;">-&gt;</span>item <span style="color: blue;">as $item</span><span style="color: purple;">) {
<span style="color: black; font-weight: bold;">15:  </span>      </span><span style="color: blue;">if </span><span style="color: purple;">( ! </span>preg_match<span style="color: purple;">(</span><span style="color: olive;">"</span><span style="color: blue;">$excludePattern</span><span style="color: olive;">"</span><span style="color: purple;">, </span><span style="color: blue;">$item</span><span style="color: purple;">-&gt;</span>title<span style="color: purple;">)) {
<span style="color: black; font-weight: bold;">16:  </span>            </span><span style="color: blue;">$filteredTitle</span><span style="color: purple;">=</span>htmlspecialchars<span style="color: purple;">(</span><span style="color: olive;">"</span><span style="color: blue;">$item</span><span style="color: olive;">-&gt;title"</span><span style="color: purple;">)</span>;
<span style="color: black; font-weight: bold;">17:  </span>            <span style="color: blue;">$filteredTitle</span><span style="color: purple;">=</span>str_replace<span style="color: purple;">(</span><span style="color: olive;">"</span><span style="color: blue;">$username</span><span style="color: olive;">: "</span><span style="color: purple;">,</span><span style="color: olive;">""</span><span style="color: purple;">,</span><span style="color: blue;">$filteredTitle</span><span style="color: purple;">)</span>;
<span style="color: black; font-weight: bold;">18:  </span>            <span style="color: green;">//Convert the time zone in China --转成亚洲时区?
<span style="color: black; font-weight: bold;">19:  </span>            </span>date_default_timezone_set<span style="color: purple;">(</span><span style="color: olive;">'Asia/Shanghai'</span><span style="color: purple;">)</span>;
<span style="color: black; font-weight: bold;">20:  </span>            <span style="color: blue;">$i</span><span style="color: purple;">++</span>;
<span style="color: black; font-weight: bold;">21:  </span>
<span style="color: black; font-weight: bold;">22:  </span>            <span style="color: blue;">if</span><span style="color: purple;">(</span><span style="color: blue;">$i</span><span style="color: purple;">&gt;</span><span style="color: blue;">$count</span><span style="color: purple;">)
<span style="color: black; font-weight: bold;">23:  </span>          {
<span style="color: black; font-weight: bold;">24:  </span>        </span><span style="color: blue;">break</span>;
<span style="color: black; font-weight: bold;">25:  </span>    <span style="color: purple;">}
<span style="color: black; font-weight: bold;">26:  </span>}
<span style="color: black; font-weight: bold;">27:  </span></span><span style="color: blue;">?&gt;
<span style="color: black; font-weight: bold;">28:  </span>&lt;</span><span style="color: maroon;">li</span><span style="color: blue;">&gt;&lt;?php echo $filteredTitle</span>; <span style="color: blue;">?&gt;
<span style="color: black; font-weight: bold;">29:  </span></span>(<span style="color: blue;">&lt;?php echo </span>date<span style="color: purple;">(</span><span style="color: olive;">"Y-m-d H:i:s"</span><span style="color: purple;">,</span>strtotime<span style="color: purple;">(</span><span style="color: blue;">$item</span><span style="color: purple;">-&gt;</span>pubDate<span style="color: purple;">))</span>; <span style="color: blue;">?&gt;</span>)<span style="color: blue;">&lt;/</span><span style="color: maroon;">li</span><span style="color: blue;">&gt;
<span style="color: black; font-weight: bold;">30:  </span>&lt;?php </span><span style="color: purple;">} } </span><span style="color: blue;">?&gt;
<span style="color: black; font-weight: bold;">31:  </span>&lt;</span><span style="color: maroon;">div </span><span style="color: red;">align</span><span style="color: blue;">="right"&gt;
<span style="color: black; font-weight: bold;">32:  </span>&lt;</span><span style="color: maroon;">a </span><span style="color: red;">href</span><span style="color: blue;">="http://twitter.com/xjb" </span><span style="color: red;">target</span><span style="color: blue;">="_blank"&gt;</span>更多...<span style="color: blue;">&lt;/</span><span style="color: maroon;">a</span><span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;
<span style="color: black; font-weight: bold;">33:  </span></span><span style="color: green;">&lt;!--  my tritter  --&gt;</span></pre>
</div>
<p><strong>源代码下载：<a href="http://watch-life.googlecode.com/files/twitter-rss.rar" target="_blank">twitter-rss.rar </a></strong></p>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/visual-studio/microsoft-web-platform.html" title="web developer tips (27):Microsoft Web Platform (2009-07-20)">web developer tips (27):Microsoft Web Platform</a> (0)</li>
	<li><a href="http://www.watch-life.net/wordpress/wp-pagenavi.html" title="wp-pagenavi 中文版 (2008-07-05)">wp-pagenavi 中文版</a> (10)</li>
	<li><a href="http://www.watch-life.net/wordpress/share-this-cn-wl.html" title="Share This &#8220;守望轩&#8221;中文版 (2008-03-19)">Share This &#8220;守望轩&#8221;中文版</a> (23)</li>
	<li><a href="http://www.watch-life.net/life-thinking/write-new-homepage-post.html" title="写在新版主页发布之时 (2008-01-11)">写在新版主页发布之时</a> (1)</li>
	<li><a href="http://www.watch-life.net/wordpress/my-rss.html" title="我的RSS我做主：My RSS (2009-02-16)">我的RSS我做主：My RSS</a> (4)</li>
	<li><a href="http://www.watch-life.net/visual-studio/use-vsual-studio-2008-develop-php.html" title="使用Visual Studio 2008 开发php程序 (2009-01-21)">使用Visual Studio 2008 开发php程序</a> (5)</li>
	<li><a href="http://www.watch-life.net/it-review/host-sharing-recommend.html" title="虚拟主机租用推荐 (2009-02-24)">虚拟主机租用推荐</a> (3)</li>
	<li><a href="http://www.watch-life.net/it-review/dreamhost-apps-no-platform.html" title="DreamHost Apps 并非平台 (2009-02-24)">DreamHost Apps 并非平台</a> (0)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：8 | <b><a href='http://www.watch-life.net/php/php-twitter-rss.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/php/php-twitter-rss.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/php/php-twitter-rss.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>近日本站google PageRank 从2升到了4</title>
		<link>http://www.watch-life.net/googleapp/google-pr-change.html</link>
		<comments>http://www.watch-life.net/googleapp/google-pr-change.html#comments</comments>
		<pubDate>Sun, 28 Sep 2008 03:18:22 +0000</pubDate>
		<dc:creator>xjb</dc:creator>
				<category><![CDATA[Google App]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[PageRank]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[女儿]]></category>
		<category><![CDATA[微博客]]></category>
		<category><![CDATA[饭否]]></category>

		<guid isPermaLink="false">http://www.watch-life.net/?p=223</guid>
		<description><![CDATA[1、近日“守望轩” 首页google pageRank 从2 上升的4.虽然pageRank 不是很高，但也是对我这半年来做网站的一个肯定的鼓励，至少关注度在增加。 2、我渐渐喜欢上了这种博客记录生活的写作方式，一方面可以整理自己的思考，一方面可以记录自己生活的点滴感受。 3、昨天在博客首页加入了“杂感”栏目，用来记录一些短的、不能大篇幅成文的短句，或者自己比较喜欢的短句和言论，本质就是一个微博客。考虑到不想再增加wordpress插件，就采用了饭否的和twitter微博客的javascrpt API来定制实现，后者作为备份，如果饭否出现问题，就更换到twitter。 效果如下图： 想要了解更过我的微博客的内容，请访问如下链接： 我的饭否：http://fanfou.com/iamxjb 我的twitter:http://twitter.com/xjb 4、十一长假今天开始了，可以好休息一下了，花时间多陪陪老婆和女儿。 相关阅读：什么是google pageRank 转自：http://www.google.cn/corporate/tech.html PageRank 技术：通过对由超过 50,000 万个变量和 20 亿个词汇组成的方程进行计算，PageRank 能够对网页的重要性做出客观的评价。PageRank 并不计算直接链接的数量，而是将从网页 A 指向网页 B 的链接解释为由网页 A 对网页 B 所投的一票。这样，PageRank 会根据网页 B 所收到的投票数量来评估该页的重要性。 此外，PageRank 还会评估每个投票网页的重要性，因为某些网页的投票被认为具有较高的价值，这样，它所链接的网页就能获得较高的价值。重要网页获得的 PageRank（网页排名）较高，从而显示在搜索结果的顶部。Google 技术使用网上反馈的综合信息来确定某个网页的重要性。搜索结果没有人工干预或操纵，这也是为什么 Google 会成为一个广受用户信赖、不受付费排名影响且公正客观的信息来源。 你可能也会喜欢以下文章： 搜索的江湖 (5) CSDN博客之星 (2) 致女儿(十二)：我不是好爸爸 (1) 初为人父（一） (33) 抓紧时间生一个吧,挺好玩的 (0) 做父母的抉择 (2) [...]]]></description>
			<content:encoded><![CDATA[<p>1、近日“<a href="http://www.watch-life.net" target="_blank">守望轩</a>” 首页<a href="http://www.google.cn/corporate/tech.html" target="_blank"><strong>google pageRank </strong></a>从2 上升的4.虽然pageRank 不是很高，但也是对我这半年来做网站的一个肯定的鼓励，至少关注度在增加。<br />
2、我渐渐喜欢上了这种博客记录生活的写作方式，一方面可以整理自己的思考，一方面可以记录自己生活的点滴感受。</p>
<p>3、昨天在博客首页加入了“<strong>杂感</strong>”栏目，用来记录一些短的、不能大篇幅成文的短句，或者自己比较喜欢的短句和言论，本质就是一个<strong>微博客</strong>。考虑到不想再增加wordpress插件，就采用了<a href="http://twitter.com/xjb" target="_blank">饭否</a>的和<a href="http://twitter.com/xjb" target="_blank">twitter</a>微博客的javascrpt <strong>API</strong>来定制实现，后者作为备份，如果<a href="http://www.fanfou.com" target="_blank">饭否</a>出现问题，就更换到<a href="http://twitter.com" target="_blank">twitter</a>。</p>
<p>效果如下图：<br />
<img src="http://www.watch-life.net/images/fanfou.jpg" alt="杂感" border="0"/></p>
<p>想要了解更过我的微博客的内容，请访问如下链接：<br />
我的饭否：<a href="http://fanfou.com/iamxjb" target="_blank">http://fanfou.com/iamxjb</a><br />
我的twitter:<a href="http://twitter.com/xjb" target="_blank">http://twitter.com/xjb</a></p>
<p>4、十一长假今天开始了，可以好休息一下了，花时间多陪陪老婆和<a href="http://www.watch-life.net/category/lovely-daughter" target="_blank">女儿</a>。</p>
<blockquote><p>相关阅读：什么是google pageRank<br />
转自：http://www.google.cn/corporate/tech.html</p>
<p>PageRank 技术：通过对由超过 50,000 万个变量和 20 亿个词汇组成的方程进行计算，PageRank 能够对网页的重要性做出客观的评价。PageRank 并不计算直接链接的数量，而是将从网页 A 指向网页 B 的链接解释为由网页 A 对网页 B 所投的一票。这样，PageRank 会根据网页 B 所收到的投票数量来评估该页的重要性。</p>
<p>此外，PageRank 还会评估每个投票网页的重要性，因为某些网页的投票被认为具有较高的价值，这样，它所链接的网页就能获得较高的价值。重要网页获得的 PageRank（网页排名）较高，从而显示在搜索结果的顶部。Google 技术使用网上反馈的综合信息来确定某个网页的重要性。搜索结果没有人工干预或操纵，这也是为什么 Google 会成为一个广受用户信赖、不受付费排名影响且公正客观的信息来源。</p>
</blockquote>
<p class="akst_link">
</p>
	<h4>你可能也会喜欢以下文章：</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.watch-life.net/it-review/google-go.html" title="搜索的江湖 (2010-03-23)">搜索的江湖</a> (5)</li>
	<li><a href="http://www.watch-life.net/it-review/csdn-blog-star.html" title="CSDN博客之星 (2009-06-20)">CSDN博客之星</a> (2)</li>
	<li><a href="http://www.watch-life.net/lovely-daughter/i-am-not-a-good-father.html" title="致女儿(十二)：我不是好爸爸 (2009-10-04)">致女儿(十二)：我不是好爸爸</a> (1)</li>
	<li><a href="http://www.watch-life.net/lovely-daughter/begin-be-father-one.html" title="初为人父（一） (2008-03-03)">初为人父（一）</a> (33)</li>
	<li><a href="http://www.watch-life.net/lovely-daughter/a-father-happy-life.html" title="抓紧时间生一个吧,挺好玩的 (2008-03-11)">抓紧时间生一个吧,挺好玩的</a> (0)</li>
	<li><a href="http://www.watch-life.net/lovely-daughter/parents-choose.html" title="做父母的抉择 (2008-12-10)">做父母的抉择</a> (2)</li>
	<li><a href="http://www.watch-life.net/it-review/visit-google-service.html" title="针对google 境外服务无法访问的临时解决方案 (2009-06-26)">针对google 境外服务无法访问的临时解决方案</a> (1)</li>
	<li><a href="http://www.watch-life.net/lovely-daughter/lovely-daughter-growth-diary-2010-06-20.html" title="女儿成长日记(2010-06-20) (2010-06-20)">女儿成长日记(2010-06-20)</a> (9)</li>
</ul>

转载请注明作者，出处，以及原始超链接。<br />评论数：11 | <b><a href='http://www.watch-life.net/googleapp/google-pr-change.html#comment'>评论这篇文章</a></b>|关注作者最近动态,欢迎 follow me <a href='https://twitter.com/xjb' target='_blank'>xjb@twitter.com</a>|联络作者：iamxjb@gmail.com<br/>© 2010 守望轩 <a href='http://www.watch-life.net/googleapp/google-pr-change.html'>www.watch-life.net</a>]]></content:encoded>
			<wfw:commentRss>http://www.watch-life.net/googleapp/google-pr-change.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.watch-life.net @ 2010-09-07 01:19:00 -->