views:

149

answers:

3

Hi, I have this-

en.wikipedia.org/w/api.php?action=login&lgname=user&lgpassword=password

But it doesn't work because it is a get request. What would the the post request version of this?

Cheers!

+3  A: 

The variables for a POST request are in the HTTP headers, not in the URL. Check urllib.

edit: Try this (i got it from here):

import urllib
import urllib2

url = 'en.wikipedia.org/w/api.php'
values = {'action' : 'login',
          'lgname' : 'user',
          'password' : 'password' }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
Adrian Mester
A: 

Since your sample is in PHP, use $_REQUEST, this holds the contents of both $_GET and $_POST.

mives
the sample is a URL, it's not in any language.
Adrian Mester
+2  A: 
params = urllib.urlencode({'action' : 'login', 'lgname' : 'user', 'lgpassword' : 'password'})
response = urllib.urlopen("http://en.wikipedia.org/w/api.php", params)

info about urllib can be found here.

Idan K