<?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>THE ENCYCLOPEDIA &#187; php</title>
	<atom:link href="http://blog.mrcongwang.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mrcongwang.com</link>
	<description>Of A Young Computer Science Graduate Student</description>
	<lastBuildDate>Mon, 17 May 2010 03:58:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>通用状态更新器</title>
		<link>http://blog.mrcongwang.com/2009/09/04/%e9%80%9a%e7%94%a8%e7%8a%b6%e6%80%81%e6%9b%b4%e6%96%b0%e5%99%a8/</link>
		<comments>http://blog.mrcongwang.com/2009/09/04/%e9%80%9a%e7%94%a8%e7%8a%b6%e6%80%81%e6%9b%b4%e6%96%b0%e5%99%a8/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 13:56:06 +0000</pubDate>
		<dc:creator>silwings</dc:creator>
				<category><![CDATA[Universal Status Updater]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xiaonei]]></category>

		<guid isPermaLink="false">http://blog.mrcongwang.com/?p=386</guid>
		<description><![CDATA[我把更新器分成了 http, XMPP, 其他
每个更新器都提供query(username, password) 和 update(username, password, status)方法
每个网站对应有自己的一个更新器
对外提供的是一个update.php页面 输入形如：
action=(query&#124;update)&#038;xml=

?View Code XML&#60;?xml version=&#34;1.0&#34; standalone=&#34;yes&#34;?&#62; 
&#60;usu&#62; 
&#60;site&#62; 
&#60;sitename&#62;renren.com&#60;/sitename&#62; 
&#60;username&#62;用户名&#60;/username&#62; 
&#60;password&#62;密码&#60;/password&#62; 
&#60;status&#62;test12345&#60;/status&#62; 
&#60;/site&#62; 
&#60;site&#62; 
&#60;sitename&#62;kaixin001.com&#60;/sitename&#62; 
&#60;username&#62;用户名&#60;/username&#62; 
&#60;password&#62;密码&#60;/password&#62; 
&#60;status&#62;test12345&#60;/status&#62; 
&#60;/site&#62; 
&#60;/usu&#62;

如果action是query 返回值形如：

?View Code XML&#60;?xml version=&#34;1.0&#34; standalone=&#34;yes&#34;?&#62; 
&#60;usu&#62; 
&#60;site&#62; 
&#60;sitename&#62;renren.com&#60;/sitename&#62; 
&#60;result&#62;状态 或者 login failed 或者 query failed&#60;/result&#62; 
&#60;/site&#62; 
&#60;site&#62; 
&#60;sitename&#62;kaixin001.com&#60;/sitename&#62; 
&#60;result&#62;状态&#60;/result&#62; 
&#60;/site&#62; 
&#60;/usu&#62;

如果为update 返回形如

?View Code XML &#60;?xml version=&#34;1.0&#34; standalone=&#34;yes&#34;?&#62; [...]]]></description>
		<wfw:commentRss>http://blog.mrcongwang.com/2009/09/04/%e9%80%9a%e7%94%a8%e7%8a%b6%e6%80%81%e6%9b%b4%e6%96%b0%e5%99%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP detect language</title>
		<link>http://blog.mrcongwang.com/2009/07/27/php-detect-language/</link>
		<comments>http://blog.mrcongwang.com/2009/07/27/php-detect-language/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 10:45:54 +0000</pubDate>
		<dc:creator>silwings</dc:creator>
				<category><![CDATA[MrCongWang.com]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.mrcongwang.com/?p=316</guid>
		<description><![CDATA[
?View Code PHPif &#40;isset&#40;$_SERVER&#91;'HTTP_ACCEPT_LANGUAGE'&#93;&#41;&#41; &#123;
&#160;
		$langs=$_SERVER&#91;'HTTP_ACCEPT_LANGUAGE'&#93;;
&#160;
&#125;
if&#40;stristr&#40;$langs,'zh-cn'&#41;&#41;&#123;
	include 'index_cn.html';
&#125;
else&#123;
	include 'index_en.html';
&#125;

]]></description>
		<wfw:commentRss>http://blog.mrcongwang.com/2009/07/27/php-detect-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating Excel using PHP</title>
		<link>http://blog.mrcongwang.com/2009/07/15/generating-excel-using-php/</link>
		<comments>http://blog.mrcongwang.com/2009/07/15/generating-excel-using-php/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:08:55 +0000</pubDate>
		<dc:creator>silwings</dc:creator>
				<category><![CDATA[SmartPolice]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.mrcongwang.com/?p=178</guid>
		<description><![CDATA[
?View Code PHPrequire_once &#34;excel.php&#34;;
$filename = &#34;anyoneyoulike.xls&#34;;
$export_file = 'xlsfile:/tmp/'.$filename;
$fp = fopen&#40;$export_file, &#34;wb&#34;&#41;;
if &#40;!is_resource&#40;$fp&#41;&#41;
&#123;
die&#40;&#34;Cannot open $export_file&#34;&#41;;
&#125;
$assoc = array&#40;
array&#40;&#34;First name&#34; =&#62; &#34;Mattias&#34;, &#34;IQ&#34; =&#62; 250,
array&#40;&#34;First name&#34; =&#62; &#34;Tony&#34;, &#34;IQ&#34; =&#62; 100,
array&#40;&#34;First name&#34; =&#62; &#34;Peter&#34;, &#34;IQ&#34; =&#62; 100,
array&#40;&#34;First name&#34; =&#62; &#34;Edvard&#34;, &#34;IQ&#34; =&#62; 100&#41;&#41;;
fwrite&#40;$fp, serialize&#40;$assoc&#41;&#41;;
fclose&#40;$fp&#41;;

Begin the download

?View Code PHPheader &#40;&#34;Expires: Mon, 26 Jul 1997 05:00:00 GMT&#34;&#41;;
header &#40;&#34;Last-Modified: &#34; . [...]]]></description>
		<wfw:commentRss>http://blog.mrcongwang.com/2009/07/15/generating-excel-using-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>获得校内状态之模拟登陆版</title>
		<link>http://blog.mrcongwang.com/2009/07/10/%e8%8e%b7%e5%be%97%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81%e4%b9%8b%e6%a8%a1%e6%8b%9f%e7%99%bb%e9%99%86%e7%89%88/</link>
		<comments>http://blog.mrcongwang.com/2009/07/10/%e8%8e%b7%e5%be%97%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81%e4%b9%8b%e6%a8%a1%e6%8b%9f%e7%99%bb%e9%99%86%e7%89%88/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 07:45:38 +0000</pubDate>
		<dc:creator>silwings</dc:creator>
				<category><![CDATA[MrCongWang.com]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xiaonei.com]]></category>

		<guid isPermaLink="false">http://blog.mrcongwang.com/?p=117</guid>
		<description><![CDATA[HTTP抓包分析如下：
在清除了所有cookie之后访问Login.do：

?View Code TEXTGET /Login.do HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: www.xiaonei.com
Connection: Keep-Alive

返回的response如下：

?View Code TEXTHTTP/1.1 200 OK
Server: nginx/0.7.58
Date: Fri, 10 Jul 2009 08:04:36 GMT
Content-Type: text/html;charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Encoding: gzip
Set-Cookie: kl=null; domain=.xiaonei.com; [...]]]></description>
		<wfw:commentRss>http://blog.mrcongwang.com/2009/07/10/%e8%8e%b7%e5%be%97%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81%e4%b9%8b%e6%a8%a1%e6%8b%9f%e7%99%bb%e9%99%86%e7%89%88/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>抓取校内状态</title>
		<link>http://blog.mrcongwang.com/2009/07/09/%e6%8a%93%e5%8f%96%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81/</link>
		<comments>http://blog.mrcongwang.com/2009/07/09/%e6%8a%93%e5%8f%96%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 15:04:04 +0000</pubDate>
		<dc:creator>silwings</dc:creator>
				<category><![CDATA[MrCongWang.com]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xiaonei.com]]></category>

		<guid isPermaLink="false">http://blog.mrcongwang.com/?p=111</guid>
		<description><![CDATA[因为我自己的校内页面是readable by everyone的 所以不需要登录验证就能抓取状态
因为校内的开发人员经常修改页面的版式 因此比较稳妥的办法是在状态中添加特征字符串
例如 &#8220;终于能把校内状态同步到主页上了&#124;www.mrcongwang.com&#8221; 就是用www.mrcongwang.com来当特征字符串
抓取代码如下：
&#60;?php
$id = $_GET['id'];
$url = &#8216;http://xiaonei.com/profile.do?id=&#8217;.$id;
try{
$subject = file_get_contents($url);
}catch(Exception $e){
 die(&#8221;&#60;p&#62;unable to connect to xiaonei.com&#60;/p&#62;&#8221;);
}
//echo $subject;
$pattern = &#8216;/&#60;p&#62;([^ ]*)www.mrcongwang.com&#60;\/p&#62;/&#8217;;
preg_match($pattern, $subject, $matches);
//print_r($matches);
echo $matches[0];
?&#62;
&#60;?php
$id = $_GET['id'];
$url = &#8216;http://xiaonei.com/profile.do?id=&#8217;.$id;
try{
$subject = file_get_contents($url);
}catch(Exception $e){
 die(&#8221;&#60;p&#62;unable to connect to xiaonei.com&#60;/p&#62;&#8221;);
}
$pattern = &#8216;/&#60;p&#62;([^ ]*)www.mrcongwang.com&#60;\/p&#62;/&#8217;;
preg_match($pattern, $subject, $matches);
echo $matches[0];
?&#62;
然后再通过一小段js利用ajax把状态写到页面上
]]></description>
		<wfw:commentRss>http://blog.mrcongwang.com/2009/07/09/%e6%8a%93%e5%8f%96%e6%a0%a1%e5%86%85%e7%8a%b6%e6%80%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
