<div>Thanks, thats a big help!</div>  <div>&nbsp;</div>  <div>only two things I don't understand well. when I create a http object with HTTPConnection() do I want this to be to my web host server (hostway.com) or to the server I'm posting to (authorize.net)?</div>  <div>&nbsp;</div>  <div>and what are the headers used for?</div>  <div>&nbsp;</div>  <div>again, thanks!</div>  <div>&nbsp;</div>  <div>Jeff<BR><BR><B><I>Graham Dumpleton &lt;graham.dumpleton@gmail.com&gt;</I></B> wrote:</div>  <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">On 05/11/2007, Alex Botero-Lowry <ALEX@PUDDLEJUMPER.FOXYBANANA.COM>wrote:<BR>&gt; On Sun, Nov 04, 2007 at 05:14:31PM -0800, Jeff Peery wrote:<BR>&gt; &gt; hello,<BR>&gt; &gt; I'm pretty new to using python on the web, I've got a bit of code<BR>&gt; &gt; that works pretty well to get form inputs and such. Now I need to post<BR>&gt; &gt; some info to a gateway service (for credit card
 processing) and then<BR>&gt; &gt; receive their response and do something with it. I can do this no<BR>&gt; &gt; problem... except that I'm not sure how to post my dictionary (name<BR>&gt; &gt; value pairs from form inputs i.e., credit card num, expire dates etc)<BR>&gt; &gt; from the cgi script. I had been using the html forms to submit data to<BR>&gt; &gt; the server, but now I need to do this from my cgi script. I think this is<BR>&gt; &gt; pretty straight forward but I didn't see anything in the cgi module.<BR>&gt; &gt; where do I start, or does anyone have some sample code? thanks!!<BR>&gt;<BR>&gt; You'll need httplib which luckily come with the stdlib so no need to install<BR>&gt; anything.<BR>&gt;<BR>&gt; Something like this should get you going:<BR>&gt;<BR>&gt; conn = httplib.HTTPConnection(remote_server)<BR>&gt; values = '&amp;'.join([ '%s=%s' % a for a in values.items() ])<BR><BR>From memory, better off using urllib.urlencode() for this as it will<BR>properly
 quote and convert special characters.<BR><BR>&gt; headers={'Content-Type':'application/x-www-form-urlencoded'}<BR>&gt; conn.request(method, url, values, headers=headers)<BR>&gt; res = conn.getresponse()<BR>&gt; data = res.read()<BR>&gt; return (res.status, res.reason, output)<BR>&gt;<BR>&gt; the important bits here are our crappy makeshift<BR>&gt; application/x-www-form-urlencoded rncoder which<BR>&gt; is the values line and our setting of the content-type. We also<BR>&gt; need to make sure the method passed to conn.request is 'POST' or<BR>&gt; 'PUT' (almost certainly POST) as these are the only ones that accept<BR>&gt; a body. I think the cgi module may have a better way of doing the<BR>&gt; encoding, but i've never found it.<BR>&gt;<BR>&gt; Alex<BR>&gt; _______________________________________________<BR>&gt; Web-SIG mailing list<BR>&gt; Web-SIG@python.org<BR>&gt; Web SIG: http://www.python.org/sigs/web-sig<BR>&gt; Unsubscribe:
 http://mail.python.org/mailman/options/web-sig/graham.dumpleton%40gmail.com<BR>&gt;<BR></BLOCKQUOTE><BR><p>&#32;__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com