def encodekeyval(key, val):
    key = urllib.parse.quote(key, '')
val = urllib.parse.quote(val, '')
return urllib.parse.quote(key + '=' + val, '')

def signature_base_string(urlstr, oauthdata):
    sigstr = 'POST&' + urllib.parse.quote(urlstr, '') + '&'
pdata = oauthdata.getpdata()
Getting 401 on Twitter OAuth POST requests