檢查出這個偉大的介紹HTTP協議: http://www.jmarshall.com/easy/http/#postmethod
你需要發送一個POST命令到HTTP服務器,然後檢查服務器的響應。我創建了我的網絡服務器叫做post.php中的PHP文件,並且它是所有
print_r($_POST);
現在,我將通過Telnet發佈一些數據吧:
justin:~ justin$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST /~justin/post.php HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 36
key1=value1&key2=value2&key3=value3
,檢查服務器的響應:
HTTP/1.1 200 OK
Date: Sat, 17 Oct 2009 06:39:02 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2 PHP/5.3.0
X-Powered-By: PHP/5.3.0
Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
Content-Length: 81
Connection: close
Content-Type: text/html
<pre>
Array
(
[key1] => value1
[key2] => value2
[key3] => value3
)
服務器說「HTTP/1.1 200 OK」,所以它的工作。
現在,作爲用於捲曲例如,需要一個類似的POST命令打包成一個字符串(這當然是字符數組,在C)。如果您對C中的字符串感興趣,請在線查看示例,您會發現很多。