<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.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://www.jackxiang.com/post//</link>
<title><![CDATA[php中几种post方法]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Tue, 02 Dec 2008 13:06:06 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	如何从一个php文件向另一个地址post数据，不用表单和隐藏的变量<br/><br/>现介绍三中方法<br/>方法1:<br/><br/><div class="code">function posttohost($url, $data) &#123;<br/>$url = parse_url($url);<br/>if (!$url) return &quot;couldn&#039;&#039;t parse url&quot;;<br/>if (!isset($url&#91;&#039;&#039;port&#039;&#039;&#93;)) &#123; $url&#91;&#039;&#039;port&#039;&#039;&#93; = &quot;&quot;; &#125;<br/>if (!isset($url&#91;&#039;&#039;query&#039;&#039;&#93;)) &#123; $url&#91;&#039;&#039;query&#039;&#039;&#93; = &quot;&quot;; &#125;<br/><br/>$encoded = &quot;&quot;;<br/><br/>while (list($k,$v) = each($data)) &#123;<br/>$encoded .= ($encoded ? &quot;&amp;&quot; : &quot;&quot;);<br/>$encoded .= rawurlencode($k).&quot;=&quot;.rawurlencode($v);<br/>&#125;<br/>$fp = fsockopen($url&#91;&#039;&#039;host&#039;&#039;&#93;, $url&#91;&#039;&#039;port&#039;&#039;&#93; ? $url&#91;&#039;&#039;port&#039;&#039;&#93; : 80);<br/>if (!$fp) return &quot;Failed to open socket to $url&#91;host&#93;&quot;;<br/><br/>fputs($fp, sprintf(&quot;POST %s%s%s HTTP/1.0&#92;n&quot;, $url&#91;&#039;&#039;path&#039;&#039;&#93;, $url&#91;&#039;&#039;query&#039;&#039;&#93; ? &quot;?&quot; : &quot;&quot;, $url&#91;&#039;&#039;query&#039;&#039;&#93;));<br/>fputs($fp, &quot;Host: $url&#91;host&#93;&#92;n&quot;);<br/>fputs($fp, &quot;Content-type: application/x-www-form-urlencoded&#92;n&quot;);<br/>fputs($fp, &quot;Content-length: &quot; . strlen($encoded) . &quot;&#92;n&quot;);<br/>fputs($fp, &quot;Connection: close&#92;n&#92;n&quot;);<br/><br/>fputs($fp, &quot;$encoded&#92;n&quot;);<br/><br/>$line = fgets($fp,1024);<br/>if (!eregi(&quot;^HTTP/1&#92;.. 200&quot;, $line)) return;<br/><br/>$results = &quot;&quot;; $inheader = 1;<br/>while(!feof($fp)) &#123;<br/>$line = fgets($fp,1024);<br/>if ($inheader &amp;&amp; ($line == &quot;&#92;n&quot; &#124;&#124; $line == &quot;&#92;r&#92;n&quot;)) &#123;<br/>$inheader = 0;<br/>&#125;<br/>elseif (!$inheader) &#123;<br/>$results .= $line;<br/>&#125;<br/>&#125;<br/>fclose($fp);<br/><br/>return $results;<br/>&#125;</div><br/>方法2:<br/><br/><div class="code"><br/>$URL=&quot;www.mysite.com/test.php&quot;;<br/>$ch = curl_init();<br/>curl_setopt($ch, CURLOPT_URL,&quot;https://$URL&quot;);<br/>curl_setopt($ch, CURLOPT_POST, 1);<br/>curl_setopt($ch, CURLOPT_POSTFIELDS, &quot;Data1=blah&amp;Data2=blah&quot;);<br/>curl_exec ($ch);<br/>curl_close ($ch);</div><br/><br/>需curl模块支持<br/><br/>方法3:<br/><br/><div class="code"><br/>$alternate_opts = array(<br/>&nbsp;&nbsp;&#039;http&#039;=&gt;array(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#039;method&#039;=&gt;&quot;POST&quot;,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#039;header&#039;=&gt;&quot;Content-type: application/x-www-form-urlencoded&#92;r&#92;n&quot; .<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;Content-length: &quot; . strlen(&quot;baz=bomb&quot;),<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#039;content&#039;=&gt;&quot;baz=bomb&quot;<br/>&nbsp;&nbsp;)<br/>);<br/>$alternate = stream_context_create($alternate_opts);<br/><br/>/* Sends a POST request directly to www.example.com<br/>* Using context options specified in $alternate_opts<br/>*/<br/>readfile(&#039;http://www.example.com&#039;, false, $alternate);</div>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] php中几种post方法]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>