Cannot get POST to work
Piet van Oostrum
piet at cs.uu.nl
Wed Sep 30 10:11:04 EDT 2009
>>>>> "tedpottel at gmail.com" <tedpottel at gmail.com> (t) wrote:
>t> Hi,
>t> I'm trying to post data to a short test script in php I wrote.
>t> The python code to do the post is
>t> import httplib
>t> #server address
>t> conn = httplib.HTTPConnection("localhost")
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
>t> #file location
>t> conn.request("POST", "/programming/bots/test.php","&ted=fred")
conn.request("POST", "/programming/bots/test.php", "ted=fred", headers)
>t> r1 = conn.getresponse()
>t> print r1.status, r1.reason
>t> data1 = r1.read()
>t> print data1
>t> conn.close()
>t> print "new ok"
>t> The PHP script is
>t> print"hello <br>";
>t> print $_POST["ted"];
>t> Ted post
--
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
More information about the Python-list
mailing list