<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[个人原创]利用PHP之file_get_contents实现Post，GET以及Cookie传输，接口调试。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Fri, 29 Jul 2011 02:45:18 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	平时我们爱使用Curl来实现Http协议的接口调试，包括Post，Get，Etc。<br/>然而，近来发现Suse enterprise sp2的64位机上没有这个Curl的PHP扩展，<br/>于是，想了想，我使用了PHP的方法来实现了对其它接口的访问，包括Cookie头的发送，简单Demo如下：<br/>vi file_get_contents.php <br/><textarea name="code" class="html" rows="15" cols="100">
&lt;?php
$skey = &quot;ajdfi&quot;;
$uin = &quot;372647693&quot;;
$post = array(&#039;name&#039;=&gt;&quot;jackxiang&quot;,&#039;blog&#039;=&gt;&quot;jackxiang.com&quot;);
$context[&#039;http&#039;] = array
(
 &#039;method&#039; =&gt; &#039;POST&#039;,
 &#039;content&#039; =&gt; http_build_query($post, &#039;&#039;, &#039;&amp;&#039;),
 &#039;header&#039;=&gt;&quot;Cookie: uin=&quot;.$uin.&quot;;skey=&quot;.$skey.&quot;&#92;r&#92;n&quot;,
 );

$context[&#039;http&#039;][&#039;header&#039;].=&quot;HOST: test3.qq.com &#92;r&#92;n&quot;;

$APIurl = &#039;http://172.25.38.**/test3.php?id=8838&#039;;
$return = file_get_contents(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$APIurl,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;false,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream_context_create($context)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
echo $return;
?&gt;
</textarea><br/><br/>接收简单Demo代码，test3.php：<br/><textarea name="code" class="html" rows="15" cols="100">
&lt;?php
echo &quot;jack&#92;n&quot;;
echo &quot;getmethod id=&quot;.$_GET[&#039;id&#039;].&quot;&#92;n&quot;;
echo &quot;postmethod&nbsp;&nbsp;&quot;.$_POST[&#039;name&#039;].&quot;&#92;n&quot;;
echo &quot;postmethod&nbsp;&nbsp;&quot;.$_POST[&#039;blog&#039;].&quot;&#92;n&quot;;
print_r($_COOKIE);
?&gt;
</textarea><br/>测试结果：<br/><br/>root@172.25.38.**:/home/jackxiang/php# php file_get_contents.php&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/><textarea name="code" class="html" rows="15" cols="100">
jack
getmethod id=8838
postmethod&nbsp;&nbsp;jackxiang
postmethod&nbsp;&nbsp;jackxiang.com
Array
(
&nbsp;&nbsp;&nbsp;&nbsp;[uin] =&gt; 372647693
&nbsp;&nbsp;&nbsp;&nbsp;[skey] =&gt; ajdfi
)
</textarea><br/>得证。EOF<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [个人原创]利用PHP之file_get_contents实现Post，GET以及Cookie传输，接口调试。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>